Pig Latin for help

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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);	
}
 
main()


WRONG.

 
int main()


RIGHT.

And though I didn't test it, I suppose that char piglatin[SIZE] = {0}; might fix it.
Last edited on
hi thanks for the advice! I tried your method but it only print "ay" for every words instead of the converted words.
Its useless program buddy its just prints "ay".Nothing else.
yeah it do only prints "ay." hi spacecamp, do you know what wrong with the code?
Topic archived. No new replies allowed.