title: Segmentation fault at checking pointer data
body: <p>I trying to insert a data in a double linked list after a specified data and it shows a segment error.</p>
  
  <pre><code>void dllinsertafter(struct node **head,int data,int data1)
  {
  struct node *temp,*newnode;
  newnode=(struct node*)malloc(sizeof(struct node));
  newnode-&gt;data=data;
  temp=*head;
  while ((temp-&gt;data)!=data1)
      temp=temp-&gt;next;
  newnode-&gt;next=temp-&gt;next;
  temp-&gt;next-&gt;prev=newnode;
  newnode-&gt;prev=temp;
  temp-&gt;next=newnode;
  }
  </code></pre>
  
  <p>No idea as to why the error is at while(temp->data!=data1).The structure used is common for double linked lists.</p>