Hi,

This is a program which converts an english phrase to pigLatin. The algorithm is to take out the first letter of the word and puts it after the last character of the english word (ignoring '\0' ) plus adding 'ay' after that. Somehow, it doesn't work. Pls direct. Thnx in advance.

Code:
#include <stdio.h>
#include <string.h>

void printLatinWord( char *s );

int main()
{
   char engPhrase[] = "This is an english sentence.";

   printf( "Original string: \n%s\n\n", engPhrase );

   printf( "String converted to pigLatin: \n" );

   printLatinWord( engPhrase );

   system( "PAUSE" );
   return 0;
}

void printLatinWord( char *s )
{
   char *tokenPtr;
   char temp[ 4 ];
   char b[ 3 ] = "ay";

   tokenPtr = strtok( s, " " );

   while ( tokenPtr != NULL ) {
      temp[ 0 ] = tokenPtr[ 0 ];
      strcat( temp, b );
      strcat( tokenPtr, temp );
      printf( "%s\n", tokenPtr );
      tokenPtr = strtok( NULL, " " );
   }
}