You are viewing a single comment's thread. Return to all comments →
when head is NULL you need to make newNode->next = NULL, else the linked list wouldn't end with a NULL.
Small modification below.
if (head == NULL) { newNode->next = NULL; return newNode; }
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a node at a specific position in a linked list
You are viewing a single comment's thread. Return to all comments →
when head is NULL you need to make newNode->next = NULL, else the linked list wouldn't end with a NULL.