dont understand why i am assigning last->next to link and then last to link.. (line 23-24). if i remove line 23, i get a segfault.
the *last pointer for tracking the last added element and link is the newly appended node. can someone explain??
i know that i wanted to point *last to *link. last->next = link will make the *next pointer point to link node but i cant understand why i did last = link
and also when i call clear() function, the head is assigned to NULL and i dont have access to linkedlist but how can i clear all the nodes from heap? do i need to free() them or they get destroyed on their own??
Do you have a whiteboard or paper and pen ? Trace the program flow and you'll understand
Обсуждают сегодня