I'm working on a homework problem that requires me to get a name from the user, and then compare that name to names from a file that I've been given.
If the name is found in the list, then I need to output it's place in the list(number). The data is in this format:
Number Boy_Name Girl_Name
1 Josh Emily
2 Jake Samantha
3 Alan Stephanie
ect.
The issue I'm having is that I can't seem to get the data to read into my variables correctly.
1 2 3 4 5 6 7
|
while(!input.eof()){
input >> name_number >> boy >> girl;
cout << "name_number is: " << name_number << endl;
cout << "boy is: " << boy << endl;
cout << "girl is: " << girl << endl;
|
This is the small bit of code that I'm having problems with. It seems that it's just reading in the same data over and over again, and not getting the next name in the list. Here is some sample output:
Please select your name to compare.
Walter
name_number is: 1
boy is: Jacob
girl is: Emily
The name Walter was not on the list for boys.
The name Walter was not on the list for girls.
name_number is: 1
boy is: Jacob
girl is: Emily
The name Walter was not on the list for boys.
The name Walter was not on the list for girls.
Press any key to continue . . .
I've been reading through my text book and googling around for a bit, any hints as to the solution to this part of the problem would be much appreciated.