0
Deleting nodes from linked list errors (C)
https://code.sololearn.com/cpCzmBkmemux/#c I'm working on nodes and i have this problem in the two functions detonanodo and detonavalore: the first one deletes the node at a certain position and the second deletes a node with a specified value, they both work but not if the node is in first or last position.
6 Respuestas
+ 2
This situation seems like someone has missed the correct handling of NULL. You need to be very careful about how you handle NULL value and the functions detonanodo you might want to change the operator at line 76. Adding head and tail handlers to the code is a good idea. Handle the first and last position separate form the rest of the list within the function.
+ 2
Guido Parlatore
No, you can add the cases for handling them within the current functions by using if or switch, whichever you prefer.
+ 2
https://code.sololearn.com/ct280pBU9UQB/?ref=app
Here, I have reworked the detonanodo function including the head and tail case(just a small if). Compare the codes to check for changes.
0
So should i create two new functions just for those two cases?
0
I tried to but it doesnt work, can you tell me how could i do it?
0
Now the function works for the last node but it still gives problem with the head