Question: This should be solved in the operators.cpp file. Write a program that will correct a C++ program that has errors in which operator, < <
This should be solved in the operators.cpp file. Write a program that will correct a C++ program that has errors in which operator, << or >>, it uses with cin and cout. The program replaces each (incorrect) occurrence of cin << with the corrected version cin >> and each (incorrect) occurrence of cout >> with the corrected version cout << Allow for the possibility that there may be any number of blank space characters (zero or more) between cin and << and between cout and >> in the source input. The replacement corrected version should have only one blank space between the cin or cout and the following operator. A blank space is the space you get from pressing a space bar (ASCII 32). All other parts of the program should be left untouched. For this assignment, you are allowed to assume the following for our input test cases: cin, cout, <<, and >> do never appear in the input file as part of string constants; cin and cout statements are written in its own single line; cin and cout statements do not contain any expressions in which contains any of characters < or >, except those which appear in the operators << and >>; and cin and cout statements may (only) be preceded with some whitespaces of any kind, not just blank spaces. Use isspace function in the library cctype to check for these whitespaces. They should be preserved in the output corrected source file. Your program should get the source file name as an input from the user. The corrected version should be output to a file with name corrected.txt and it should also be displayed on the terminal. That means output of your program (after getting the file name) should be exactly same as the contents of the file corrected.txt. Your program should define a function that is called with the input- and output-file streams as arguments. Suppose that in a session, the file original.txt contains the following text. #include using namespace std; int main(){ cout >> "Hello!"; return 0; } The execution of the program should look like the following (including whitespace and formatting): Enter filename: original.txt #include using namespace std; int main(){ cout << "Hello!"; return 0; } File corrected.txt consists of the above output except first two lines.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
