having trouble read from a file

hello everyone
I tried to read in a file that contain studentId(8 integer long) and GPA in the same line separated by a comma and white space, but I couldn't. Any help is appriciated
example: 145453565, 4.0
34344443, 3.9
23454345, 3.4
12345678, 3.4

void studentRecord::loading(string filename)
ifstream infile;
int studentId;
double GPA;

string temp;

if(!infile.is_open() )
cout << "ERROr" << endl;
getline(infile, temp);
int pos = temp.find(',');
temp.substr(0, pos);
temp >> studentId;
temp.substr(pos, temp.size())
temp >> GPA;


Last edited on
Topic archived. No new replies allowed.