I need to gather the total of ALL of those numbers. Here's what I got:
1 2 3 4 5 6 7 8 9
string name, data;
double sum( 0. );
ifstream in_stream( "myData.txt" );
while( getline(in_stream, name) ) // if you can get a name
{
getline( in_stream, data); // then get the number!
in_stream.ignore(1, '\n'); // ignore the new lines
cout << data << endl; // output what you found
}
This outputs:
1.000
2.000
3.000
These are held as strings however, I have no clue how to cast these into doubles to add them all up. sum += static_cast<double>(data) doesn't work :(