Traversing a tree using C. It will accept a character and prints the post fix/ in fix/ pre fix. The problem is when it prints the output it looks like this
 input
 a
 b
 c
 d
 e
 f
 g
 h
 i   
    IN ORDER:   C abcdefghi
    PRE ORDER:  C  abcdefghi
    POST ORDER:  ihgfedcba C
There are spaces and the character 'C' when I traverse and the pre and post order is wrong. I dont know what is wrong. I am wrong in getting the input here? using scanf to get the address of the char? Here is the whole code
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
typedef struct BST
{
    char data;
    struct BST *lchild, *rchild;
}node;
node *get_node()
{
    node *temp;
    temp=(node *)malloc(sizeof(node));
    temp->lchild=NULL;
    temp->rchild=NULL;
    return temp;
}
void insert(node *root, node *new_node)
{
    if((new_node->data) < (root->data))
    {
            if((root->lchild)==NULL)
            {
                root->lchild=new_node;
            }
            else
            {
                insert(root->lchild,new_node);
            }
    }
    if(new_node->data > root->data)
    {
        if((root->rchild)==NULL)
        {
            root->rchild=new_node;
        }
        else
        {
            insert(root->rchild,new_node);
        }
    }
}
void inorder(node *temp)
{
    if(temp!=NULL)
    {
        inorder(temp->lchild);
        putchar(temp->data);
        inorder(temp->rchild);
    }
}
void preorder(node *temp)
{
    if(temp!=NULL)
    {
            putchar(temp->data);
            preorder(temp->lchild);
            preorder(temp->rchild);
    }
}
void postorder(node *temp)
{
    if(temp!=NULL)
    {
        postorder(temp->lchild);
        postorder(temp->rchild);
        putchar(temp->data);
    }
}
void main()
{
    int i;
    node *new_node, *root, *tmp, *parent;
    node *get_node();
    char c;
    clrscr();
    for(i=0;i<9;i++)
    {
        fflush(stdin);
        new_node=get_node();
        printf("\nenter element: ");
        scanf("%c", &new_node->data);
        if(root==NULL)
        {
            root = new_node;
        }   
        else
        {
            insert(root, new_node);
        }
    }
    printf("\n\nIN ORDER: ");
    inorder(root);
    printf("\nPRE ORDER: ");
    preorder(root);
    printf("\nPOST ORDER: ");
    postorder(root);
    getch();
}
 
    