I'm just doing some practice with linked list as to study and ran into a problem.
So far I have 4 functions: build a list forward, moving a node from front to back and deleting front, sorting an unsorted list, and a display. The first 2 functions work just fine, but when I execute the program the function to sort the list doesnt work and outputs the same thing as my function to move a node to the back. I don't know if it has something to do with the functions or if I just can't build an unordered LL in the same program as an ordered linked list.
All sortList does currently is leak memory. The only way first and last are assigned a value is if they were null when the function was entered, and they are not.
Logically a function called sortList should sort a list that already exists. It should not be reading from a file (and, in fact, it probably doesn't since infile is a global stream that has already reached end-of-file.)