Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 

IN C++ PLEASE

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions

Question

What is meant by disparity in sentencing?

Answered: 1 week ago

Question

3. List ways to manage relationship dynamics

Answered: 1 week ago