You are viewing a single comment's thread. Return to all comments →
SinglyLinkedListNode *new_node = new SinglyLinkedListNode(data); new_node->data = data; new_node->next = NULL;
SinglyLinkedListNode *ptr; if(head == NULL) { head = new_node; return head; } else { ptr = head; while(ptr->next != NULL) { ptr = ptr->next; } ptr->next = new_node; new_node->next = NULL; return head; }
Seems like cookies are disabled on this browser, please enable them to open this website
Insert a Node at the Tail of a Linked List
You are viewing a single comment's thread. Return to all comments →
SinglyLinkedListNode *new_node = new SinglyLinkedListNode(data); new_node->data = data; new_node->next = NULL;