Question: Write and test a C++ program that reads the content of the file word by word, convert each word to plural form and print it
Write and test a C++ program that reads the content of the file word by word, convert each word to plural form and print it back to the user in reverse order. Develop the following function: string* readWords(string file name, int& size): This function should read the file given by file name word by word, save the words into an array of strings an return it to the called the function need to open the file twice, one to count the number of words and the other time is to read them into the dynamic array. Develop the following function: string change to.plural (string word); Use the following rules: o if noun ends in y" remove the "y" and add "ies." o if noun ends in "s" or "sh" add "es" o all other cases just add "s" Complete the following main: int main({ //TODO 1: declare all required variables //TODO 2: read all the words in the file input.txt into a dynamic array using the readWords function. //TODO 3: print the words in plural form to the user in reverse order //TODO 4: free any dynamic memory ) For the following input file: input.txt chair diary boss circus fly dog clue dish Your program should print: dishes clues dogs flies circuses bosses diaries chairs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
