I am trying to print inorder, the data of a BST. This works with simple recursion, however I can not figure out how to print a newline at the end of the printed data, before the function returns to the calling code.
/* Print data for inorder tree traversal on single line,
* separated with spaces, ending with newline. */
void printTree(struct TreeNode* root)
{
if(root)
{
printTree(root->left);
printf("%d ", root->data);
printTree(root->right);
}
}