#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int a , b , c , d;
ifstream myfile;
myfile.open ("numbers.txt");
myfile >> a, b, c;
d = a + b + c;
ofstream myfile;
myfile.open ("result.txt");
myfile << d;
myfile.close();
return 0
}
The number.txt
file contains 3 numbers 10
, 8
, 9
. I am trying to get the program to read them and sum them up in the results.txt.
The errors I get are:
conflicting declaration 'std :: ifstream myfile'
no match for 'operator << in myfile << d'
'myfile' has a previous declaration as 'std :: ifstream myfile'