Teacher\'s Instructions In each progject, you should open the files using any pa
ID: 3887432 • Letter: T
Question
Teacher's Instructions
In each progject, you should open the files using any paths to folders but remember that on a Windows system, you must use the '' character when specifying directories. If you copy the input file to the same directory as your project executible, you can simply open statements using the following:
cin >> filename; // where the user enters "hw4pr1input.txt"
inputFileStream.open(filename);
That means the input and output files need to be in the same folder as your compiled and linked executable code (your EXE file). That will vary by compiler, but it is not difficult to place your files in the correct folder. I don't want to see paths to folders on your computer, those paths will not work on mine when I go to grade your homework. If I have to modify your open statements or if I have to answer prompts for file names I will count off.
This solution simply opens and iterates through the text file of names until a match is found. It could be improved by making case-insensitive matches.
Text Book Question
Write a C++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 whitespace characters (one or more) between cin and << and between cout and >>. The replacement corrected version has only one blank between the cin or cout and the following operator.
Your program should get the source filename 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 filename) 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. (File name babynames2012.txt)
Explanation / Answer
Following is the code for above scenario:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.