Pig Latin program...

Discuss all aspects of programming here.

Moderator: The Mod Squad

Pig Latin program...

Postby Snowfire » Fri Mar 18, 2005 11:40 am

Howdy all, I'm trying to make a program that ill convert a string that the user inputs into a pig latin string. Here is the code that I have so far:


#include <iostream>

using std::cout;
using std::cin;
using std::endl;

#include <cstring>

void printPigLatin( char * );

int main()
{

char string[ 25 ];

cout << "nter-Eay a tring-say o-tay e-bay onverted-cay o-ayt ig-Pay atin-Lay : ";

cin.getline(string, 25, '\n');

char *stringptr;

stringptr = strtok( string, " " );

printPigLatin( stringptr );

while ( stringptr != NULL ) {
stringptr = strtok( NULL, " " );
if (stringptr!=NULL)
printPigLatin( stringptr );
}

return 0;
}

void printPigLatin( char *stringptr )
{

int size = strlen( stringptr );

char PigString[25]={0};

PigString[size] = stringptr[0];

cout << PigString << "<--test\n\n";

for ( int i = 1; i < size; i++ ){
PigString[i]=PigString[i+1];
}

cout << PigString << "<--real\n\n";

}

Yet through all this I still can't figure this out. Any ideas?
Tono Sien


Love is the greatest conspiracy, by the most loving genius.
Snowfire
Black Belt 1st Degree
Black Belt 1st Degree
 
Posts: 1486
Joined: Sun May 11, 2003 8:47 pm
Location: Omaha, NE

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest