Add some debug code to the program that prints out the full list every time it is changed. For each node, print out its value and its links.
Then as the code is executed you can immediately see...
Type: Posts; User: Norm
Add some debug code to the program that prints out the full list every time it is changed. For each node, print out its value and its links.
Then as the code is executed you can immediately see...
One of the steps in designing a linked list is to use paper and pencil to draw a list.
Then work out how the links need to be changed for the various changes that can be made to the list:
add at...
Ok, then the code is working correctly? I thought you said there was a problem:
It's only printing my last element.
Is the list properly chained? The loop stops when the prev link is null.