I am trying to read a data from the file, but i am unable to do it. I am using code blocks IDE version 16.01.
my code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream read_file;
read_file.open("rfile.txt");
int numFromFile=0,sum;
while(!read_file.eof())
{
read_file >> numFromFile;
sum+=numFromFile;
}
cout <<"sum of numbers :" << sum << endl;
read_file.close();
return 0;
}