I have a file that contains names and grades. It looks like this
Mike 60
Joe 25
Steve 80
...
This file is opened inside a function. Here is the function:
This function works, but in only passes the name into the vector (grades)Code:void Bag_of_Grades::input_file () { ifstream grades_stream ; grades_stream.open ( "D://C++//notes//streams_data1.dat" ) ; string name; int score; while ( grades_stream >> name >> score) { grades.push_back ( name ); } }
I tried alot of stuff including:
But I can't get this rightCode:grades.push_back ( name , score ); or grades.push_back ( name ); grades.push_back ( score ); or grades.push_back ( name >> score);
How can I pass the name and the score to the vector ?