You are viewing a single comment's thread. Return to all comments →
the statement p->next=temp; needs to be out of the while loop. You assign after you traverse the whole list, not at every node.
Insert a Node at the Tail of a Linked List
You are viewing a single comment's thread. Return to all comments →
the statement p->next=temp; needs to be out of the while loop. You assign after you traverse the whole list, not at every node.