/* Convert one word of English to Pig Latin. Do not move an initial vowel to the end. Preserve capitalization. */ #include #include #include #define N 256 /* maximum string length, including the '\0' */ main() { char english[N]; char piglatin[N]; char suffix[] = "?ay"; printf("Please type a word and press RETURN.\n"); scanf("%s", english); if (strchr("AEIOUaeiou", english[0]) != NULL) { suffix[0] = 'w'; strcpy(piglatin, english); } else { suffix[0] = english[0]; strcpy(piglatin, english + 1); if (isupper(suffix[0])) { suffix[0] = tolower(suffix[0]); piglatin[0] = toupper(piglatin[0]); } } strcat(piglatin, suffix); printf("In Pig Latin, %s is %s.\n", english, piglatin); }