title: Segmentation fault while finding middle element in a linked list
body: <p>I'm trying to find the middle element of a linked List, but I'm getting a segmentation fault, and I'm not sure what is going wrong. This is my implementation of the hare rabbit algorithm:</p>
  
  <pre><code>//fast slow pointer method  
  void ptMiddle(struct node **head_ref)
  {   
      struct node *fast = (*head_ref);
      struct node *slow = (*head_ref);
      fast = fast-&gt;next;
  
      while(fast!=NULL)
      {   
          // printf("%d%d",slow-&gt;data,fast-&gt;data);
          slow = slow-&gt;next;
          fast = fast-&gt;next-&gt;next;
      }
      printf("Middle elemnet is:%d\n",slow-&gt;data);
  }
  
  int main()
  {
      struct node * head=NULL;
      push(&amp;head,1);
      push(&amp;head,2);
      push(&amp;head,3);
      push(&amp;head,4);
      printList(&amp;head);
      printf("M:%d\n",middleNode(&amp;head)-&gt;data);
      printf("here");
      append(&amp;head,5);
      append(&amp;head,6);
      printList(&amp;head);
      printf("M:%d\n",middleNode(&amp;head)-&gt;data);
      printf("here");
      ptMiddle(&amp;head);
  
      return 0;  
  }
  </code></pre>
  
  <p>Please help out.</p>