I have been spending some hours now, implementing a linked list and some functions for it in C.
- It is doubly linked (a node has a link to two nodes, one in front and one behind it).
- Whenever a node is added to a list, it should be added in the 'right' place, ie. the list is ordered by the content of the nodes, so it's always sorted.
I've made it work, and it does what it is supposed to. However, my make_node function suffers from a massive brainfart I'm having right now, and I used a goto in it. It's pretty disastrous, and it's hard to keep track on things. If anyone could take a look and see if they would be able to help me fix it (I'm still suffering from my brainfart and can't see the way), I would be very happy.
The comment in the code about the function should show how things are intended to work.
Code.
Thanks in advance.
- It is doubly linked (a node has a link to two nodes, one in front and one behind it).
- Whenever a node is added to a list, it should be added in the 'right' place, ie. the list is ordered by the content of the nodes, so it's always sorted.
I've made it work, and it does what it is supposed to. However, my make_node function suffers from a massive brainfart I'm having right now, and I used a goto in it. It's pretty disastrous, and it's hard to keep track on things. If anyone could take a look and see if they would be able to help me fix it (I'm still suffering from my brainfart and can't see the way), I would be very happy.
The comment in the code about the function should show how things are intended to work.
Code.
Thanks in advance.
