Question: USING C++ Given the following program readline.cpp and the data file input.txt: // Program readline.cpp demonstrates how to read a line of text from a

USING C++

Given the following program readline.cpp and the data file input.txt:

// Program readline.cpp demonstrates how to read a line of text from a file #include #include #include using namespace std; int main() { string str1, str2, str3, str4; // declares 4 variables ifstream inData; // declares input stream ofstream outData; // declares output stream inData.open("input.txt"); // binds program variable inData to the input file "input.txt" outData.open("output.txt"); // binds program variable outData to the output file "output.txt" // input 4 lines getline(inData,str1); getline(inData,str2); getline(inData,str3); getline(inData,str4); // output 4 lines outData << str4 << endl; outData << str3 << endl; outData << str2 << endl; outData << str1 << endl; // outputs 4 lines inData.close(); outData.close(); return 0; } 

The input data file input.txt.

Allan Smith John Cooper Zhang Hua Yao Ming 

You are required to deliver the following:

Edit/create the input data file input.txt and the program file readline.cpp.

Compile and run the program readline.cpp.

Check the content of the output data file by cat output.txt in hercules or notepad for Visual Studio users.

Modify the program readline.cpp to work with your new input data file.

Compile and run this C++ program.

Run the program for your lab instructor and show the result in output.txt.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!