title: How to fix the problem of file.exe stop running after one insertion in linked list
body: <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  struct node{
      int id;
      char name[50];
      float point;
      char grade;
      struct node *next;
      };
  struct node *head;
  void DataEntry(struct node *);
  void GetData(struct node *);
  void DataDisp();
  
  void Insert()
  {
      struct node *p;
      p=(struct node*)malloc(sizeof(struct node));
      DataEntry(p);
      if(head==NULL)
      {
          head=p;
  
      }
      else
      {
  
          struct node *q;
          q=head;
          while(q!=NULL)
          {
              q=q-&gt;next;
          }
          q-&gt;next=p;
          p-&gt;next=NULL;
  
      }
  
  
  }
  void DataEntry(struct node *p)
  {
          printf("Enter value of Id employee\n");
          scanf("%d",&amp;p-&gt;id);
          printf("Enter name of the person\n");
          scanf("%s",p-&gt;name);
          printf("Enter points got by Employee\n");
          scanf("%f",&amp;p-&gt;point);
          printf("Enter grade of the person\n");
          fflush(stdin);
          scanf("%c",&amp;p-&gt;grade);
  }
  void GetData(struct node *q)
  {
      printf("The data entered by you is as follows\n");
      printf("Id is %d\n",q-&gt;id);
      printf("Name is %s\n",q-&gt;name);
      printf("Point is %f\n",q-&gt;point);
      printf("Grade is %c\n",q-&gt;grade);
  }
  void DataDisp()
  {
      struct node *z;
      z=head;
      if(z==NULL)
      {
          printf("List is Empty\n");
          return;
      }
      while(z!=NULL)
      {
          GetData(z);
          z=z-&gt;next;
      }
  }
  int main()
  {
      Insert();
      DataDisp();
  }
  </code></pre>
  
  <p>I have implemented a singly linked list, I insert data in a list using Insert() function and displaying the data using DataDisp() function in DataDisp() function I have used GetData() function which is accessing data from linked list nodes. The problem here is I can do the first insertion and it displays data also using DataDisp() but after that, there is error file.exe stop running. I think there is a segmentation fault; I tried my best to solve the problem but could not run it successfully. Please help.</p>