title: C compilation warning: passing argument 1 of ‘insert’ from incompatible pointer type [enabled by default]
body: <pre><code>/*Implementation of Binary Tree*/
  
  #include &lt;stdio.h&gt;
  #include &lt;ncurses.h&gt;
  #include &lt;malloc.h&gt;
  #include &lt;stdlib.h&gt;
  
  struct bin_tree
  {
      int INFO;
      struct node *LEFT, *RIGHT;
  };
  
  typedef struct bin_tree node;
  
  node *insert(node *,int); /*Function prototype for insering a new node*/
  void display(node *); /*Function prototype fpr displaying the tree nodes*/
  
  int count=1; /*counter for ascertaining left or right position for the new node*/
  
  int main()
  {
      struct node *root = NULL;
      int element, choice;
  
      clear();
  
      /*Displaying a menu of choices*/
      while(1)
      {
          clear();
          printf("\n Select an option\n");
          printf("\n1 - Insert");
          printf("\n2 - Display");
          printf("\n3 - Exit");
  
          printf("\n\nEnter your choice: ");
          scanf("%d",&amp;choice);
  
          switch(choice)
          {
              case 1:
              {
                  printf("\n\n Enter the node value: ");
                  scanf("%d", &amp;element);
                  root = insert(root, element); /*calling the insert function for    inserting a new element into the tree*/
                  getch();
                  break;
              }
  
              case 2:
              {
                  display(root); /*calling the display function for printing the node values*/
                  getch();
                  break;
              }
  
              case 3:
              {
                  exit(1);
                  break;
              }
  
              default:
              {
                  printf("\n incorrect choice.Please try again.");
                  getch();
                  break;
              }
           }
      }
  }
  
  node *insert(node *r, int n)
  {
      if(r==NULL)
      {
          r=(node*)malloc(sizeof(node));
          r-&gt;LEFT = r-&gt;RIGHT = NULL;
          r-&gt;INFO = n;
          count = count+1;
      }
      else
      {
          if(count%2==0)
          r-&gt;LEFT = insert(r-&gt;LEFT,n);
          else
          r-&gt;RIGHT = insert(r-&gt;RIGHT,n);
      }
      return(r);
  }
  
  void display(node *r)
  {
      if(r-&gt;LEFT!=NULL)
      display(r-&gt;LEFT);
      printf("%d\n",r-&gt;INFO);
      if(r-&gt;RIGHT!=NULL)
      display(r-&gt;RIGHT);
  }   
  </code></pre>
  
  <hr>
  
  <pre><code>gcc -Wall -c "BinaryTree.c" (in directory: /home/dere/IGNOUPROGRAMS/C)
  
  BinaryTree.c: In function ‘main’:
  BinaryTree.c:46:5: warning: passing argument 1 of ‘insert’ from incompatible pointer type [enabled by default]
  BinaryTree.c:16:7: note: expected ‘struct node *’ but argument is of type ‘struct node *’
  BinaryTree.c:46:10: warning: assignment from incompatible pointer type [enabled by default]
  BinaryTree.c:53:5: warning: passing argument 1 of ‘display’ from incompatible pointer type [enabled by default]
  BinaryTree.c:17:6: note: expected ‘struct node *’ but argument is of type ‘struct node *’
  BinaryTree.c: In function ‘insert’:
  BinaryTree.c:86:3: warning: passing argument 1 of ‘insert’ from incompatible pointer type [enabled by default]
  BinaryTree.c:74:7: note: expected ‘struct node *’ but argument is of type ‘struct node *’
  BinaryTree.c:86:11: warning: assignment from incompatible pointer type [enabled by default]
  BinaryTree.c:88:3: warning: passing argument 1 of ‘insert’ from incompatible pointer type [enabled by default]
  BinaryTree.c:74:7: note: expected ‘struct node *’ but argument is of type ‘struct node *’
  BinaryTree.c:88:12: warning: assignment from incompatible pointer type [enabled by default]
  BinaryTree.c: In function ‘display’:
  BinaryTree.c:96:2: warning: passing argument 1 of ‘display’ from incompatible pointer type [enabled by default]
  BinaryTree.c:93:6: note: expected ‘struct node *’ but argument is of type ‘struct node *’
  BinaryTree.c:99:2: warning: passing argument 1 of ‘display’ from incompatible pointer type [enabled by default]
  BinaryTree.c:93:6: note: expected ‘struct node *’ but argument is of type ‘struct node *’
  Compilation finished successfully.
  </code></pre>
  
  <p>Would appreciate any help on this error.</p>