+ 1
I don't know why i can't use append function. Func cause programme to crashed as getting to it in for loop.
2 Réponses
+ 1
I solve it my self, the only problem is from traverse function. where we check if ((cursor->next! = NULL)) (cause run time error) but i can't find any reason for this!!!
https://code.sololearn.com/cZi0Eecr3qxw/?ref=app
- 1
Your append() function intends to insert a new node before Head. It successfully patches the next pointer that used to point to Head, to point to the new element, but it doesn't write tge new element's next pointer to the original Head.
You should add:
newNode->next = Head;
Before line 58
Also change || to && on line 48:
while(cursor->next != NULL && cursor->next != Head){