Question: The following is for a C++ assignment. The instructor gave us the following instructions: Ideas for implementing this one: ***************** It is not acceptable if
The following is for a C++ assignment.
The instructor gave us the following instructions:
Ideas for implementing this one:
***************** It is not acceptable if you read the entire file into memory (such as an array or vector) the print out to the output file ******************
- read the last line of input file and print it to the output file:
-- start from the back of the file, such as in.seekg(0, ios::end)
-- use a while loop to move towards the front of the file
-- check each byte to see if a new line char (' ') is present.
-- if a newline char is found, call getline(in, line) where line is a string var. Output line to output file
- loop to move towards to beginning of the input file.
Thank you!
E8.7 Write a program that reads each line in a file, reverses its lines, and writes them to another file. Suppose the user specifies input.txt and output.txt when prompted for the file names, and input.txt contains the lines Mary had a little lamb Its fleece was white as snow And everywhere that Mary went The lamb was sure to go. After the program is finished, output.txt should contain The lamb was sure to go. And everywhere that Mary went Its fleece was white as snow Mary had a little lamb
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
