title: Print Binary Tree in C
body: <p>How can i display an binary tree in c?,
  like this </p>
  
  <pre><code>         37
        /      \
      16        3
     /  \       / \
    9   26    58  81
          \   / \
          35 55  74
  </code></pre>
  
  <p>i can display level by level </p>
  
  <p>1
  23
  4567
  89</p>
  
  <p>but i need draw this BTs in the exactly format</p>
  
  <pre><code>void printLevel(NoArvore * node , int level)
  {
    if(node != NULL &amp;&amp; level == 0)
    {
    printf("%d",node-&gt;number);
    printf("====");
    }
    else if(node != NULL){
  
      printLevel(node-&gt;left,level-1);
      printLevel(node-&gt;right,level-1);
    }
  }
  
  void printElements(NoArvore *node)
  {
    int i,spaces;
    int levelCount = getHeight(node);
    int Hspace =  getHeight(node);
  
    for(i = 0; i &lt; levelCount;i++)
    {
      for(spaces = 0; spaces &lt;= (Hspace*Hspace)-(i+3);spaces++)
       printf("=");
      printLevel(node,i);
      printf("\n");
    Hspace--;
    }
  }
  </code></pre>
  
  <p>with this code, i have this output</p>
  
  <pre><code>==============37====
  ======16====76====
  9====26====58====81====
  35====55====74====
  </code></pre>