Task
Write a C program that removes confidential information from a text file by replacing it with different data.
Your program will be invoked as
./[your-program] [input-file] [output-file] [string-to-remove] [string-to-insert]
Here, [your-program] is your compiled program and the other elements are the parameters passed to your program.
When your program is invoked like this, it should replace every occurence of [string-to-remove] in file [input-file] with [string-to-insert] and write the result to [output-file].
After the invocation of your program [input-file] and [output-file] should be identical except the replaced parts.
While replacing the target string, the matching of the target string should be CASE-SENSITIVE.
FOR THIS PROGRAM, YOU ARE NOT ALLOWED TO USE ANY EXTERNAL COMMAND.
YOUR PROGRAM SHOULD BE A PURE C PROGRAM THAT ONLY MAKES USE OF STANDARD C LIBRARIES.
Sample Input File (original.txt)
People say that CS60 is hard.
I agree but CS60 is fun, too.
We can divide all students into two groups.
Those who like CS60 and those who don't like CS60.
Sample Invocation
./[your-program] original.txt changed.txt CS60 paintball
Sample Output File (changed.txt)
People say that paintball is hard.
I agree but paintball is fun, too.
We can divide all students into two groups.
Those who like paintball and those who don't like paintball.
Hints
For this assignment, you will need to learn how command line parameters are read by C programs. Google for it, if necessary.
Assumptions and Constraints
You may assume that different occurrences of the string to be removed do not overlap.
You may assume that the input file's size does not exceed 1 Megabytes.
You may assume that the length of the string parameters are at most 1024.
Submission
Submit the source code for your program (.c file) through the submission system.