Question: C++ Program Help: This program reads in 3 numbers from the file infile.txt, sums the numbers, and writes the sum to the file outfile.txt. Here's

C++ Program Help: This program reads in 3 numbers from the file "infile.txt", sums the numbers, and writes the sum to the file "outfile.txt".

Here's my source code:

#include #include //must include this header file for streams

using namespace std;

int main() { ifstream in_stream; ofstream out_stream;

//open the files in_stream.open("infile.txt"); out_stream.open("outfile.txt");

int first, second, third;

in_stream >> first >> second >> third;

//display the sum of the first 3 numbers out_stream

return 0; }

Here's my infile: C++ Program Help: This program reads in 3 numbers from the file

Here's my outfile: "infile.txt", sums the numbers, and writes the sum to the file "outfile.txt".

My answer is that large number "1717986916"... but it should be 3. Why is my answer that large number?

nfile Notepad File Edit Format

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!