You are given a file named "course_roster.txt" containing an ordered list of all students in the class. Each name is on its own line in the file and is listed in the following format:
Your program should prompt the user and accept the first name and then the last name of a student (assume that the user enters both names in all capitals). Using this input, you must determine the rank of the student according to the list in the file. If the name is not found, you should report it to the user.
then my solution will work, do you not understand? Here is a little clearer.
1 2 3 4 5 6 7 8 9 10 11
string temp, name;
cout << "Please Enter a name as shown : LAST,FIRST" << endl;
int rank = 1; //holds rank/line
while(getline(cin,temp)) // get line check if line matches user input
if(temp == name)
cout << "User rank is " << rank << endl;
++rank; // doesnt match then increment count to represent current rank/line