Have segmentation error in my code of circular LL

#include

using namespace std;

class node{
public:
int data;
node* next;

node(int d)
{
	this->data=d;
}

};

void push(nodehead,int data)
{
node
a=new node(data);
node*temp=head;

a->next=head;

if(head!=NULL)
{
	while(temp->next!=head)
	{
		temp=temp->next;
	}
	temp->next=a;
}
else
{
	a->next=a;
}

head=a;

}

void print(nodehead)
{
node
temp=head;
while(temp->next!=head)
{
cout<data<<" <- ";
temp=temp->next;
}
cout<data<<“END”;
}

int main()
{
#ifndef ONLINE_JUDGE
freopen(“input.txt”,“r”,stdin);
freopen(“output.txt”,“w”,stdout);
#endif
node*head=NULL;

push(head,2);
push(head,3);
push(head,10);
push(head,30);
push(head,40);




print(head);
cout<<endl;

return 0;
}

hi @iamsairus10 please save your code on ide.codingblocks.com and share the link.

@iamsairus10 made a couple of changes here https://ide.codingblocks.com/s/226716

what is if( ! head) means?

@iamsairus10 (head != NULL) is equivalent to !head , NULL is treated as a boolean false and !NULL is treated as a boolean true

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.