Hi
Copy and paste the following program to see if it does what you want. Your original sample program does not do that job!
Best regards
Chong
Code:
//#include <stdio.h>
#include <iostream.h>
#include <string.h>
#define SIZE 90
void convertPigLatin(char *word,char *p);
main()
{
char word[SIZE];
char piglatin[SIZE];
//printf("Input: ");
cout << "Input:";
//scanf("%s", word);
cin >> word;
convertPigLatin(word,piglatin);
//printf("Pig Latin: %s\n", piglatin);
cout <<"Pig Latin: " << piglatin << '\n';
}
void convertPigLatin(char *word, char *p)
{
char *pig_latin="ay";
char *after, *before;
char *tmp=p;
char tmp_word[SIZE];
strcpy(tmp_word,word);
strcpy(p,word);
//*(p+strlen(word))=NULL;
while (strchr("aeiouAEIOU",*tmp_word) == NULL)
{
char consonant=*tmp_word;
before=tmp_word+1;
while (*before)
*(p++)=*(before++);
*p=consonant;
p=tmp;
strcpy(tmp_word,p);
}
strcat(p, pig_latin);
}