Question: Here is sample code to read and write text data using files. int value1; ifstream finput(input.txt); finput >> value1; ofstream foutput(output.txt); foutput < < value1;

Here is sample code to read and write text data using files.

int value1; ifstream finput("input.txt"); finput >> value1; 
ofstream foutput("output.txt"); foutput << value1; foutput.close(); 

Now, let us say each column of data (sample given below) has been stored in a separate file (file1.txt, file2.txt, file3.txt, filen.txt). We need to read all the data files, find the total of each row of data and output the values to output.txt. Let us assume that all the specified data files have same # of lines & it does not exceed 1000. Assume that there will be maximum 10 data files.

Here is some sample data, actual data can be anything:

file1.txt file2.txt file3.txt filen.txt
1 2 3 10
10 20 30 100

Program should accept a list of filenames in one line, read the data from all those files and total each row of data. Corresponding output.txt will look like

55 550 ...

C++ PLEASE

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!