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

Description: In this homework, you will implement reading & writing to files and

ID: 3885070 • Letter: D

Question

Description: In this homework, you will implement reading & writing to files and passing by reference Problem: You will be given a list of words in a file. You must then replace all words that start with any of the characters in a list (from command line args). Finally, you will output the changed list to a file You will be reading your arguments from the command line. The name of the input file will be passed into your program as argument 1, argv [1]. The name of the output file will be passed into your program as agument 2,argv (21. The number of words will be passed into your program as argument 3,argv[3]. The letters to replace will be passed into your program as argument 4, argv [41 You must create an array called words, then you must read the contents of this file into it. You must use the function: void readFile (string fileName, string words, int numberOfwords) Then for every character in the list of characters, replace all words that start with the that character. These words will be replaced with four dashes, You must use the function: void replaceword (string &word;, char toReplaceInWord) Then you must write the array words to file in. You must use the function: void writeFile (string fileName, string words[l, int numberOfWords)

Explanation / Answer

int main(int argc, char* argv[]){ char* s=argv[1]; char input[256]; s = input; printf("Please enter a string: "); scanf("%s ", s); int str_length = 0; while (s[str_length] != '') { str_length++; if (s[str_length] == '') break; } printf("%d ", str_length); return 0; }