title: Binary Search Tree node deletion error
body: <p>I've created my binary search tree and gave the pointer to the node which I want to delete into my <code>*p</code>. </p>
  
  <p>The delete method is supposed to be deleting the node which is pointed at by <code>*p</code> and should add the subtrees with <code>addtree</code> to my root.  <code>*pBaum</code> is the pointer which points to my root.</p>
  
  <p>However im getting an error message called "conflict types" on <code>addtree</code> everytime I declare </p>
  
  <pre><code>Baum = addtree(Baum, p-&gt;right);
  </code></pre>
  
  <p>I also get a warning "assignment makes pointer from integer without a cast"</p>
  
  <p>My struct contains left &amp; right pointer to the subtrees and a pointer to the content.</p>
  
  <pre><code>struct tnode
  {
  int content;
  struct tnode *left; /* linker Teilbaum */
  struct tnode *right; /* rechter Teilbaum */
  };
  
  // Deletes the node where *p is pointing at
  
  struct tnode  *deletenode(struct tnode *p, struct tnode *pBaum)
  {
     struct tnode *Baum = pBaum;
  
      if ((p-&gt;left == NULL) &amp;&amp; (p-&gt;right == NULL))
      {
        free(p);
      }
      if ((p-&gt;left == NULL) &amp;&amp; (p-&gt;right != NULL))
      {
        Baum = addtree(Baum, p-&gt;right);
        free(p);
  
      }
      if ((p-&gt;right == NULL) &amp;&amp; (p-&gt;left !=NULL))
      {
        Baum = addtree(Baum, p-&gt;left);
        free(p);
      }
      if ((p-&gt;left != NULL) &amp;&amp; (p-&gt;right !=NULL))
      {
        Baum = addtree(Baum, p-&gt;right);
        Baum = addtree(Baum, p-&gt;left);
        free(p);
      }
    return Baum;
  }
  
  // Adds the Subtrees to my root
  
  struct tnode *addtree(struct tnode *top, struct tnode *p)
  {
  if (p == NULL)
      return top;
  else
  return addtree(addtree(addelement(top, p-&gt;content),p-&gt; right),   p-&gt;left);
  
  // Adds a node to my Tree
  
  struct tnode *addelement(struct tnode *p, int i)
  {
  int cond;
  if (p == NULL)
  {
      p = talloc(); /* make a new node */ p-&gt;content = i;
      p-&gt;left =p-&gt;right =NULL;
  }
  else if (p-&gt;content == i)
  {
      return p;
  }
  else if (i &lt; p-&gt;content) /* goes into left subtree */ p-&gt;left =addelement(p-&gt;left, i);
  else /* goes into right subtree */ p-&gt;right = addelement(p-&gt;right, i);
  return p;
  }
  
  // Looks for the node which is supposed to get deleted and returns a pointer to it 
  
  struct tnode *searchnode(struct tnode *p, int nodtodelete)
  {
  if (p == NULL)
  {
      printf("Baum ist leer oder Element nicht vorhanden \n");
      return NULL;
  }
  if ( p -&gt; content == nodtodelete)
  {
      return p;
  }
  if (p-&gt;content &lt; nodtodelete)
  {
      return searchnode (p-&gt;right, nodtodelete);
  }
  if (p-&gt;content &gt; nodtodelete)
  {
      return searchnode(p-&gt;left, nodtodelete);
  }
  }
  }
  
  int main()
  {
  struct tnode *Baum = NULL;
  struct tnode *tmpPos = NULL;
  Baum = addelement (Baum, 32);
  Baum = addelement(Baum, 50);
  Baum = addelement(Baum, 60);
  tmpPos = searchnode(Baum,50);
  Baum = deletenode(tmpPos, Baum);
  }
  </code></pre>