I have a text file which can be seen below. I wish to read the file and then use the second integer in the file. However, the code which I am currently using simply takes the first integer and the string. Whilst I want it to take the second integer and the string.
So my question is, how is this possible? And can it be done with getLine()?
The file which I am trying to read and the code can be seen below:
File:
10202 CE151 17.5
10105 CE151 99.9
10202 CE151 5.6
10406 CE301 59.8
10103 CE151 75.5
10709 CE204 67.2
Code:
string mod;
float mark;
getline(file2, s2);
istringstream line(s2);
line >> mark;
line >> mod;
cout << mod << endl;
cout << mark << endl;
1 Answer