Linked lists and file i/o, and some other stuff
Hereīs the deal: Iīve been working on a project recently that heavily depends on linked lists and to be able to save and load them. What makes the matter more complex is the fact that I want to load the list in to an allready existing list, that is first to be deleted (I donīt really know too much about lists and how to optimize them). All of the code fragments below are parts of different functions.
This is how I delete the list and make it ready to be reloaded (probably filled with stuff that does not need to be there and perhaps even some real errors):
This is what I use to load the list:
And this is how I use the list (where i KNOW there are errors, just canīt figure out how to fix them):
/* here is quite a bit of code that is not relevant, I know it does what itīs
supposed to, so it doesnīt really matter. */
temp, int1 and int2 are parts of another linked list, which I know to work. This entire sequense of code is used to get to the matching spot in the two linked lists.
Something in that last code fragment makes the .exe crash. Please help me fix this!
Any help will be welcomed, both help with the real problem and optimizing of code.
Iīve tried to modify my code to what was suggested,
but the program crashes when I start it.
It uses a linked list successfully once, but then it isnīt reseted to the start when next I use it, so I get a nasty error where the program forever tries in vain to raech a node it has allready past.
So how do I reset to the beginning of the list? I assumed from the example above that... ...did just that.
Am I wrong and thatīs whatīs wrong with my code?
Or am I right and thereīs something completely different thatīs wrong?