You are viewing a single comment's thread. Return to all comments →
Node* Insert(Node *head,int data) { struct Node *temp,*tail,*ptr; temp=new Node; temp->data=data; temp->next=NULL; if(head==NULL) { head=temp;} else { ptr=head; while(ptr!=NULL) { tail=ptr; ptr=ptr->next; } tail->next=temp; } return head;
}
bro i think you missed the struct function and above is the soln that worked for me pm me if you find any problem
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 →
Node* Insert(Node *head,int data) { struct Node *temp,*tail,*ptr; temp=new Node; temp->data=data; temp->next=NULL; if(head==NULL) { head=temp;} else { ptr=head; while(ptr!=NULL) { tail=ptr; ptr=ptr->next; } tail->next=temp; } return head;
}
bro i think you missed the struct function and above is the soln that worked for me pm me if you find any problem