Alright, so basically, let's say I cant have a pointer to the last node in my linked list, but I still want to be able to remove a student based on a name entered by the user.
Code: here
Student_list is the head of my list, and the rest (curr, prev, next) is pretty obvious. My 2 questions are:
1. What would I replace the two instances of 'last' with in the last part of the function (lines 8 and 9)
2. What would be the best way to cycle through my list to check to see if the name exists, and if not, how to tell the user?
Im guessing for question #2 it would be something like this:
while((curr->name)!=input )
{prev=curr;
curr=curr->next;}
but then how would I notify the user if the name entered does not exist? All my feeble brain could come up with was something like this:
if((curr->next)==NULL&&(curr->name)!=input
cout<<"stuff"
It's relatively easy stuff, but I get easily confused. Any help is appreciated like always, thanks!
Code: here
Student_list is the head of my list, and the rest (curr, prev, next) is pretty obvious. My 2 questions are:
1. What would I replace the two instances of 'last' with in the last part of the function (lines 8 and 9)
2. What would be the best way to cycle through my list to check to see if the name exists, and if not, how to tell the user?
Im guessing for question #2 it would be something like this:
while((curr->name)!=input )
{prev=curr;
curr=curr->next;}
but then how would I notify the user if the name entered does not exist? All my feeble brain could come up with was something like this:
if((curr->next)==NULL&&(curr->name)!=input
cout<<"stuff"
It's relatively easy stuff, but I get easily confused. Any help is appreciated like always, thanks!