#include<stdio.h>
#include<stdlib.h>
struct node
{
    int data;
    struct node *next;
};
struct node *head;
void insert(int a)
{
    struct node* temp=(struct node*)malloc(sizeof(struct node));
    struct node* temp1;
    if(head=NULL)
    {
        temp->data=a;
        temp->next=NULL;
        head=temp;
        return;
    }
    {
        temp1=head;
        temp->data=a;
        while(temp1->next!=NULL)
        {
            temp1->next=temp;
        }
    }
}
void print()
{
    struct node* temp2;
    temp2=head;
    while(temp2->data!=NULL)
    {
        printf("the data are %d",temp2->data);
    }
}
int main()
{
    int n,a,i;
    printf("how many number");
    scanf("%d",&n);
    head=NULL;
    for(i=0;i<=n;i++)
    {
        printf("enter the no. to store");
        scanf("%d",&a);
        insert(a);
        print();
    }
}
I don't know what is wrong with this program. Everytime i try to compile this program an error occurs: "segmentation fault (core dumped)". I'm doing this program in Ubuntu. What does segmentation fault mean and how can I fix it?
 
     
    