title: Incompatible pointer type error using structs
body: <p>I am new to programming. I am trying to learn C and pointers, but it is giving me much trouble.
  I got the following error trying to implement a singly linked list.  I searched online, and I couldn't find someone who had an error just like mine, or perhaps I just didn't couldn't make sense of it with my problem.</p>
  
  <p>The following is the error I received:</p>
  
  <p>warning: incompatible pointer types initializing 'NODE *'
        (aka 'struct node *') with an expression of type 'struct NODE <em>'
        [-Wincompatible-pointer-types]
          NODE</em> temp = (*l)->head;</p>
  
  <pre><code>    NODE* temp = (*l)-&gt;head;
  </code></pre>
  
  <p>In main, I passed the address of the variable of type LIST.  So, I thought I had to dereference 'l', to get the address of where the LIST type is located, then I had to dereference with an arrow to get the address of where the NODE is located.  Where am I confused?  I do appreciate the help.</p>
  
  <p>Below you will see the code I have written:</p>
  
  <pre><code>typedef struct node {
      int value;
      struct node* next;
  }NODE;
  
  typedef struct list{
      struct NODE* head;
  }LIST;
  
  void insert(LIST** l, int x){
  
      if((*l)-&gt;head == NULL){
  
        NODE* new_Node = (NODE*) malloc(sizeof(NODE));
        new_Node-&gt;next = NULL;
        new_Node-&gt;value = x;
      }
  
      NODE* temp = (*l)-&gt;head;
  
      while(temp-&gt;next != NULL){
        temp=temp-&gt;next;
      }
  
      NODE* new_Node = (NODE*) malloc (sizeof(NODE));
      temp-&gt;next = new_Node;
      new_Node-&gt;next = NULL;
      new_Node-&gt;value = x;
  }
  
  int main(){
  
      LIST *l = (LIST*) malloc(sizeof(LIST));
  
      insert(&amp;l, 5);
  
      return 0;
  }
  </code></pre>