I'm having a problem with C++ programming language, please help me out. I'm writing a program that asks the user to enter a student ID and the program will extract the information of the student who has that ID from a list of 15 students in my .txt file. I have these lines of codes:
void Person_list::changeName() { Person *s; string name; int id; int temp_id; s = head; cout << "Please enter student's ID: "; cin >> id; while ((s!=NULL) && (s -> getID() != id)) { s = s -> next; } if (s != NULL) { s -> Show(); } if (s == NULL) { cout << "Cant find" << endl; } } What I want to do is to ask the user to enter the students ID again (until the user enters an appropriate number) if the program can't find the student ID (for example when I enter 16, the program is not able to find a student because my list only contains 15 students). Any idea how to do this? thanks.
P/s I'm not allowed to use nullptr
Person *FindById(int id);and remove unused variables.do { /**/ } while (s == nullptr);may do the job.nullptr. May you useNULL? They are two names for the same thing.NULL, but disallowsnullptr, then please replace the professor.