I am new to c++ and this website, so I will try to do this correctly. My problem is to take two input files from the user, not knowing how many integers exist on the two files, and create an output file with the largest, smallest, and average of the numbers from the two files. I know I have to use an array, but don't know exactly how. Thanks. Here is what I have so far:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
usingnamespace std;
int main ()
{
cout<<"Please enter the first file name for the data you would like to be calculated\n";
string in_file, in_file2, out_file;
cin>>in_file;
cout<<"Please enter the second file name for the data you would like to be calulated\n";
cin>> in_file2;
cout<<"I will find the largest, smallest, and the average of the numbers from these two files and write them to an output file. Please enter the name of the file you would like these values to be output to.\n";
cin>> out_file;
ifstream in_stream, in_stream2;
ofstream out_stream;
in_stream.open(in_file);
if (in_stream.fail())
{
cout<<"Input file opening failed.\n";
exit(1);
}
in_stream2.open(in_file);
if (in_stream2.fail())
{
cout<<"Input file opening failed.\n";
exit(1);
}
out_stream.open(out_file);
if (out_stream.fail())
{
cout<<"Output file opening failed.\n";
exit(1);
}
}