You are viewing a single comment's thread. Return to all comments →
This is becase when you used Node *temp, you just made a pointer of type Node, No memory was allocated as in the pratik9044536615's code where he uses
new Node();
So, I would suggest allocating memory either using new Node() or go all C style and use
Node *temp = (Node *)malloc(sizeof(Node));
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 →
This is becase when you used Node *temp, you just made a pointer of type Node, No memory was allocated as in the pratik9044536615's code where he uses
So, I would suggest allocating memory either using new Node() or go all C style and use