In pig-latin if the word starts with a constonant, then all the letters of that word up to a vowel are added to the end.
I made this code to do this. Could someone look over it as I really havnt had much practice with arrays and cstring.nerds -> erds-nay
shake -> ake-shay
translate -> anslate-tray
Does it look good? Any changes or recommendations to make it better (without using more complex C++) ?Code:void con_PLatin (char word[], const int length) { char temp[20]; char tempword[25]; char chartemp; int i = 1; int j = 0; int a = 0; int length_tempword; chartemp = word[0]; strcopy (temp, chartemp); do { if (strchr("bcdfghjklmnpqrstvwxyz", word[i]) { chartemp = word[i]; strcat (temp, chartemp); i++; } } while(strchr("bcdfghjklmnpqrstvwxyz", word[i]); do { tempword[j] = word[j]; j++; }while (j < length); length_tempword = strlen(tempword); do { word[a] = tempword [a]; a ++ } while (a < length_tempword); strcat (word, "-"); strcat (word, temp); strcat (word, "ay"); return; }




Reply With Quote