Hi, I'm doing a linked list for a waiting list that is sorted by bribes (If student A pays 5 dollars and student B pays 6 dollars, student B will be in front of student A). For some reason, when I try to output my results I always receive an endless loop, where all I see is the very last student and his bribe being outputted over and over again. I have not yet written the Insert After function, so whenever I input numbers they are always bigger than the ones before (The purpose of Insert After is to insert the student and bribe, if the bribe is the lowest of all those inputted, at the end of the list.
Line 108, you allocate a new PersonRec in AddToList.
Line 124, you allocate a new PersonRec in AddToList.
Line 58, you allocate a new PersonRec in InsertBefore which is called from AddToList.
So, for one insertion, you potentially allocate 3 new nodes. Does that seem right to you?
ViewList should be const. Then the compiler could warn you about modifying head and leaking all your memory.
Advance is not correct. You only modify the local pointer. (It shouldn't be a member function anyway. It doesn't access any members.)
There is no need at all in AddToList for any pointers to pointers.
At no time do you modify any of the links for the (potentially 3) new PersonRecs you allocate in AddToList, so they all point to random places in memory.