Question: simple C program the assign2 text file given contains the following paragraph below The Traveller had little theterest the the appartheus and walked back and
Given a file, "assgn2_input.txt", uploaded into the assignment folder, create a program with the following functionality. You may use the program in p. 20 of the textbook as a starting template. Create the following function: o int convert_copyfile(const char* namel, const char* name2) o this function should return the number of conversions made ("the" to "THE"). If the target file (second argument) doesn't exist, then your program should create an empty file for writing. If the target file (second argument) exists, then your program should exit with error message without doing anything. Use the combination of option flags in open() system call we covered in the class. Use BUFSIZE=100 to iteratively read bytes from the input file and write converted bytes into the output file. (Use while loop as in the example program.) While reading bytes, you should o keep track of the number of occurrences of "the" word in the file. (Case sensitive) While writing bytes to the output file, you should o Replace any occurrence of the word with THE word. o Then, write back the modified contents to the output file. Create main() function which makes the following call: Convert_copyfile("assign2_input.txt", "assgn2_output.txt"); Print out the total number of conversions made (from "the" to "THE); Print out the contents of "assgn2_output.txt" file at the end of your program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
