title: C: binary tree searching method
body: <p><br />
  I'm trying to make a search method using a binary tree(no, it's not a binary search tree, just a binary tree) using a recursive function. If the data is on the binary tree, i want it to return the node and if it is not, i want it to return a <code>NULL</code> value. I have made the search function and it's doing its job perfectly. But the problem is, it seems that the function won't return the node.</p>
  
  <p>Here's the <code>struct</code> for the binary tree:</p>
  
  <pre><code>struct data
  {
      int number;
      struct data *left, *right;
  }*root = NULL;
  </code></pre>
  
  <p>and this is the search function i'm talking about:</p>
  
  <pre><code>data* search(struct data *node, int key)
  {
      if(node == NULL)
          return NULL;
      else
      {
          printf("\n%d %d -", node-&gt;number, key);
  
          if(node-&gt;number== key)
              return node;
  
          search(node-&gt;left, key);
          search(node-&gt;right, key);
      }
  }
  </code></pre>
  
  <p>When i'm calling the search function like this: <code>search(root, 6);</code> , it says that it's returning a <code>NULL</code> value although i have pushed a <code>6</code> number into the binary tree(and the search function stops right at the <code>return node;</code> line too, so i'm assuming that the function is returning a <code>NULL</code>.) </p>
  
  <p>I have seen a tutorial for binary tree in <a href="http://www.cprogramming.com/tutorial/lesson18.html" rel="nofollow">here</a>  , used and changed some code from it, but it's still the same. i'm desperately looking for help right here :(</p>