Reading string from outside data file
Hi everyone,
I'm trying to read data from a text file, which looks like this:
Toots Sweet 87 76 90 -1
Willy Nilly 73 63 74 70 -1
Phil O'Sophy -88
Jill Quirk 84 73 83 -3
I delcare first name and last name as string, and score as double.
By using the code below, I cannot read all the data in the file but only the first record. If I take out system("pause"), the program will go crazy with endless line of record.
Code:
while (!in.eof())
{
in >> fname >> lname >> score;
cout << fname << lname << score << endl;
system("pause");
}
I'm new with programming, can anyone give me some advice please?