Some hints:
The condition for your while loop compares target and SENTINEL. Neither one of the variable is changed inside the while loop. Thus the loop, if entered, does not have a possibility to terminate.Code:while (target != SENTINEL)
The while loop iterates (wrongly as I pointed out earlier) over each line of the file. Thus a line is printed out for each line in the search file. But what you actually want is first to search through the file and after you are done, print a line if the search was successful or not.Code:while (! input.eof()) { input >> lastName >> parkingSticker; if (target == parkingSticker) cout << "The parking sticker number belongs to " << lastName << endl; else cout << "This parking sticker is not on file. Try again." << endl; }




Reply With Quote