title: I have a problem with deleting a node in tree data structures in C
body: <p>The code in the delete function works for nodes having 1 child and leave nodes, but when I enter 12 (the node has 1 child), that node is still there, is there any problem with the delete function :</p>
  
  <pre><code>void Delete(struct Node *current, int data){
       struct Node *X;
       if((current == NULL)
           printf("Can not delete that node since the tree is empty");
       else{
           if(data &gt; current-&gt;data)
               Delete(current-&gt;rightchild, data);
           else(data &lt; current-&gt;data)
               Delete(current-&gt;leftchild, data);
           else{
               X = current;
               if(current-&gt;leftchild == NULL){
                   current = current-&gt;rightchild;
               }
               else(current-&gt;rightchild == NULL){
                   current = current-&gt;leftchild;
               }
               X = NULL;
            }
  }
  
  int main(){
      int tree[7] = {5, 4, 15, 3, 12, 20, 13};
      struct Node *current;
      int I = 0;
      for(; I &lt; 7; ++I){
          Tree(tree[I]); // Tree is the tree-creating function
      }
      current = root;
      printf("Entering the node u want to delete: ");
      scanf("%d", &amp;j);
      Delete(current, j);
      InOrder_Traversal(root); // this is the printing function
  </code></pre>
  
  <p>I expect the output 3, 4, 5, 12, 13, 15, 20 to be 3, 4, 5, 13, 15, 20, but the node 12 is still there when I enter 12.</p>