SEGMENTATION FAULT: CICULAR LINKED LIST

https://ide.codingblocks.com/s/319681 Refer to this link plz.

Hey @mverma_be19
In your code on line 17, you are saving the address of head in temp.
But if head ==NULL then you are changing where the head points to but temp is still pointing to NULL.
That’s why while loop involving temp will give you segmentation error.
To resolve this ,after line 21 add temp=head;
i.e
if(head==NULL)
{
head=n;
temp=head;
}

This will resolve your issue.
Also, you are not printing all the nodes in print function so try to resolve that on your own :slight_smile: