Circular linked list
showing segmentation fault
Hey @divyam_13
In inser function add this corner case when head is NULL
if(head==NULL){
head=n;
head->next=head;
return ;
}
And also in print function u need to print last node data as well because loop will stop for it
say we have only 1 node then its next is already head so it wont print anything
so add
cout<<temp->data;
After while loop ends
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.