// Reads three nubers form the file infile.dat, sums the nubers, // and writes the sum to the file outfile.dat. # include # include # include int main() { using namespace std; ifstream in_stream; ofstream out_stream; in_stream.open("infile.txt"); if (in_stream.fail()) { cout << " infile failed to launch" << endl; exit(1); } out_stream.open("outfile.txt"); if (out_stream.fail()) { cout << " outfile failed to launch"; exit(1); } int first, second, third; in_stream >> first >> second >> third; out_stream << "The sum of the first 3\n" << "numbers in infile.txt\n" << "is " << (first + second + third) << endl; in_stream.close(); out_stream.close(); return 0; }