Hello, I'm new to c++ and i'm making program to read from numbers from file and calculate average.
The numbers in file is like this
10; 15; 200
and my source so far
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("numbers.txt");
if (myfile.is_open())
{
while ( myfile.good() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unable to open file";
system("PAUSE");
return 0;
}
So, can anyone explain me, how convert that string to few ints in order to calculate average?
Thanks in advance