title: accessing nodes of linked list using double pointers
body: <p>I am trying to add nodes in a linked list, passing the pointer of pointer, accessing the member (*list) -> next gives a segmentation fault. Can someone point out the mistake, thanks in advance. The code is</p>
  
  <pre><code>void initializeList (node ** head, int data)
  {
      *head = malloc (sizeof (node));
      (*head)-&gt; member = data;
      (*head)-&gt; next = NULL;
  }
  
  void addNode(node ** list, int data)
  {
      node * newNode = NULL;
      newNode = malloc (sizeof (node));
      while (*list-&gt;next!= NULL) 
      {
          *list= (*list) -&gt; next;
      }
      newNode -&gt; member = data;
      newNode -&gt; next = NULL;
      (*list) -&gt; next = newNode;
  }
  
  void main ()
  {
      node * head = NULL;
      initializeList (&amp;head, 5);
      addNode(&amp;head, 6);
  }
  </code></pre>