Question
WRITE USING C++ Command line tool: You are to develop a program that will change all occurances of one string in a file to a
WRITE USING C++
Command line tool: You are to develop a program that will change all occurances of one string in a file to a different one. Your program will read from the standard input and write to the standard output. For example, if your program is called prog1 here is an example of calling it:
bin01010% ./prog1 input output < file1.txt > file2.txt
The result of executing this command is that file2.txt is a copy of file1.txt, with every instance of the string input replaced by output.
Your program will be graded on style (readability, by the grader) and correctness.
This problem will be the first program for you to turn in electronically. If it does not compile correctly, you will get no credit for this problem.
DETAILS
To simplify grading, your program should read all input from standard input (cin) and write all output to standard output (cout). Do not prompt the user or produce any additional output.
To have a file act as though it was typed into the keyboard, you can run your program like the following:
bin01010% ./prog1 yellow duck black pig < file1.txt > file2.txt
The < symbol is for file redirection, which means that when your program executes a cin instruction, it will read from file1.txt rather than the keyboard. The > symbol is for file redirection, which means that when your program executes a cout instruction, it will write to file2.txt rather than the screen.
What to turn in
For this assignment turn in at least one header file in at least one header file, and at least two source files, one of which will be built into a library, and one of which will call a function referenced in the header from from the library, as well as a makefile to build the library and executable. Please put your output files in their standard locations, /include, /lib, and /bin or ./ for the final executable. You are expected to turn in the program code and your makefile. All I should have to do to compile your program is type make. Typing make should generate an executable file called prog1, as well as ensuring all other files are in their proper file structure. Do not submit executable files, or .o files. If I type make and your program does not compile, you will get no credit. Be sure to submit all the files necessary to compile your program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started