Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

x.Hmm stuck again I figure out my last question because I put it in the wrong ar

ID: 3618170 • Letter: X

Question

x.Hmm stuck again I figure out my last question because I put it in the wrong area of my code. I am having problems with my function definition for Rules. Here is my code:

Explanation / Answer

x.Xce="Courier New">#define _CRT_SECURE_NO_DEPRECATE #include #include #include void Enter(char word[]); void CopyString(char word[], char newword[]); void Rules(char word[], char newword[]); void SaveWord(char word[], FILE *outptr); void Quit(char *again); int main(){ char again =' '; char word[20]=""; char newword[20]=""; FILE *outptr; outptr= fopen("out.txt","w"); do{ Enter(word); CopyString(newword, word); SaveWord(word,outptr); SaveWord(newword,outptr); Rules(word, newword); Quit(&again); printf(" choice entered %c ", again); }while(again!='n'&& again!='N'); } void Quit(char *again){ printf(" Would you like to enter another word yes(y) or no(n): "); scanf("%c", again); } //function definition that asks the user to enter a word and reads it from the user void Enter(char word[]) { printf(" Enter a word: "); scanf("%s", word); } //function definition that uses strcpy to copy the original word from the word array to the newword array void CopyString(char newword[], char word[]) { strcpy(newword, word); } //function definition that uses the a conditional to figure out which rule to use and add the plural addition by strcat void Rules(char word[], char newword[]){ int length; length = strlen(word); if (word[length-1] == 'Y'){ strcat(&newword[length-1],"IES"); printf("Rule is 1"); } else if (word[length-1] == 'y'){ strcat(&newword[length-1],"ies"); printf("Rule is 2"); } else if ((word[length-1] == 'H' && word[length-2] == 'C') || (word[length-1] == 'H' && word[length-2] == 'S') || (word[length-1] == 'S')){ strcat(&newword[length-1],"ES"); printf("Rule is 3"); } else if ((word[length-1] == 'h' && word[length-2] == 'c') || (word[length-1] == 'h' && word[length-2] == 's') || (word[length-1] == 's')){ strcat(&newword[length-1],"es"); printf("Rule is 4"); } else if (isupper(word[length-1])){ strcat(&newword[length-1],"S"); printf("Rule is 5"); } else if(islower(word[length-1])){ strcat(&newword[length-1],"s"); printf("Rule is 6"); } } void SaveWord(char word[], FILE *outptr){ printf(" ------------------------------------ "); printf(" The word on the screen is: %s ", word); fprintf(outptr," The word in the file is: %s ", word); }