How to make expression tree from postfix expression?
<p>I want to create tree in C++.
I could compile the code without errors or warnings, but i don't get an output.</p>

<p>I think error is in inorder fn, but don't know how to remove this.</p>

<pre><code>#include&lt;iostream.h&gt;
#include&lt;conio.h&gt;
#include&lt;stdlib.h&gt;

struct tree
{
    int data;
    struct tree * left;
    struct tree * right;
};
typedef struct tree * TREE;

TREE maketree(int x)
{
    TREE tree = (TREE)malloc(sizeof(tree));
    if(tree == NULL)
    {
        return NULL;
    }
    tree-&gt;left = tree-&gt;right = NULL;
    tree-&gt;data = x;
return tree;
}

void setleft(TREE tree,int x)
{
    if(tree == NULL || tree-&gt;left != NULL)
    {
        cout&lt;&lt;"\t Error !! Inserting New Node At Left Side  !\n";
    }
    else
    {
        tree-&gt;left = maketree(x);
    }
}

void setright(TREE tree,int x)
{
    if(tree == NULL || tree-&gt;right != NULL)
    {
        cout&lt;&lt;"\t Error !! Inserting New Node At Right Side !\n";
    }
    else
    {
        tree-&gt;right = maketree(x);
    }
}

void inorder(TREE root)
{
    if(root != NULL)
    {
        TREE left=root-&gt;left;
        TREE right=root-&gt;right;
        inorder(left);
        cout&lt;&lt;root-&gt;data;
        inorder(right);
    }
}

void main()
{
clrscr();
    TREE root = NULL,child,parent;
    int i,j = 1;
    cout&lt;&lt;"Root Of Binary Search Tree :- ";
    cin&gt;&gt;i;
    root = maketree(i);
    cout&lt;&lt;"\n\n";
    while(i)
    {
        cout&lt;&lt;j&lt;&lt;" Node Value:- ";
        cin&gt;&gt;i;
        if(i &lt; 0)
        {
            break;
        }
        parent = child = root;
        while((i != parent-&gt;data) &amp;&amp; (child != NULL))
        {
            parent = child;
            if(i &lt; parent-&gt;data)
            {
                child = parent-&gt;left;
            }
            else
            {
                child = parent-&gt;right;
            }
        }
        if(i == parent-&gt;data)
        {
            cout&lt;&lt;"\t Value "&lt;&lt;i&lt;&lt;" Already Present In BST !!\n";
        }
        else if(i &lt; parent-&gt;data)
        {
            setleft(parent,i);
        }
        else
        {
            setright(parent,i);
        }
        j++;
    }
    inorder(root);
getch();
}
</code></pre>
