You are setting the head to
NULL
inside
create()
and assign that (now
NULL
) to
next
:
void create(int num)
{
head=NULL;
node *temp;
temp=(node*)malloc(sizeof(node));
temp->data=num;
temp->next=head;
head=temp;
return;
}
So remove the indicated line and initialise
head
when declaring it:
node head = NULL;