#include<iostream> #include<fstream> #include<cstdlib> // for exit
using namespace std;
int main() {
ifstream fin;
ofstream fout;
fin.open("input.txt");
if(fin.fail()) { // fail to open the file cout << "Input file opening failed.\n"; exit(1); // exit the program }
fout.open("output.txt"); if(fout.fail()) { // fail to open the file cout << "Output file opening failed.\n"; exit(1); // exit program }
int first, second, third; fin >> first >> second >> third; fout << "The sum of the first 3 numbers are " << (first + second + third) << endl;
fin.close(); fout.close();
return 0; }
|