Hi, I was just playing around with Pig Latin & I came across this codes somewhere. I was trying to debug it, there was no error but I got weird error like this.
Input: happy
Pig Latin: 汤汤汤汤汤汤汤汤汤汤汤汤汤汤汤汤汤汤汤汤汤 appyhay
Any c++ expert know how can i fix it? Thanks.
Code:
#include <stdio.h>
#include <string.h>
#define SIZE 90
void convertPigLatin(char *word, char *piglatin);
main()
{
char word[SIZE];
char piglatin[SIZE];
printf("Input: ");
scanf("%s", word);
convertPigLatin(word, piglatin);
printf("Pig Latin: %s\n", piglatin);
}
void convertPigLatin(char *word, char *piglatin)
{
char *pig_latin="ay";
char *after, *before;
while (strchr("aeiouAEIOU",*word) == NULL)
{
char consonant=*word;
piglatin=word, before=word+1;
while (*before)
*piglatin++=*before++;
*piglatin=consonant;
}
strcat(piglatin, pig_latin);
}