It disapears after i enter the name of out_file_name
I have system("pause") at the end because im using a dev compiler and if that pause isnt put ther the program will run real fast and disapear off the screen. the system ("pause") prevents that.
thank you
Code:
#include < fstream>
#include<iostream>
#include <cstdlib>
int main()
{
using namespace std;
char in_file_name[16], out_file_name [16];
ifstream in_stream;
ofstream out_stream;
cout << "I will sum six numbers taken from input\n"
<< "file and write the sum to an output file.\n";
cout << "Enter the input file name (maximum of 15 characters): \n";
cin >> in_file_name;
cout<< "Enter the output file name (maximum of 15 characters): ";
cin >> out_file_name;
// its right here that the program disapears off the screen
cout << "I will read numbers from the file"
<< in_file_name << "and\n"
<< "place the sum in the file\n"
<< out_file_name <<endl;
in_stream.open(in_file_name);
if (in_stream.fail())
{
cout << "Input file opening failed.\n";
exit(1);
}
out_stream.open(out_file_name);
if (out_stream.fail())
{
cout << "Output file opening failed.\n";
exit(1);
}
int first, second, third, fourth, fifth, sixth;
in_stream >> first >> second >> third >> fourth >> fifth >> sixth;
out_stream << "The sum of the first 3\n"
<<"numbers in" << in_file_name << endl
<< "is" <<(first+second+third+fourth+fifth+sixth)
<< endl;
in_stream.close();
out_stream.close();
cout <<"end of program.\n";
system("pause");
return 0;
}



