title: Binary Search Tree Printing
body: <p>I am working on a Binary Tree program for school and I have everything working perfectly. All I am working on now is the proper output. My teacher wants the output to be all the numbers in sorted order with commas after them.</p>
  
  <p>My code that I have sorts the numbers perfectly and prints them, I am just not sure how to remove the comma after the last number.</p>
  
  <p>Current Output: 1, 2, 3, 4,</p>
  
  <p>Needs to be: 1, 2, 3, 4</p>
  
  <p>Here is my code:</p>
  
  <pre><code>void BinaryTree::inorder(tree_node* p)
  {
      if(p != NULL)
      {
          if(p-&gt;left) 
              inorder(p-&gt;left);
  
          cout &lt;&lt; p-&gt;data &lt;&lt; ", ";
  
          if(p-&gt;right)
              inorder(p-&gt;right);
      }
      else
          return;
  }
  </code></pre>
  
  <p>I have tried a few things to make it right but I just can't figure it out.</p>
  
  <p>Any help would be great.</p>
  
  <p>Thanks.</p>