c语言数据结构二叉树求结点层次有bug

这代码有几处bug,
一是求结点层次会不准确
二是main里的第一个scanf不能输入
这bug咋改啊


 
#include <stdio.h>
#include <stdlib.h>
#define N 100
typedef char datatype;
typedef struct node     /*二叉树结构定义*/
{
    datatype data;
    struct node *lch,*rch;
}bnode;
void fstorder(bnode *p)      /*先序递归遍历二叉树*/
{
    if(p)
    {
        printf("%c",p->data);
        fstorder(p->lch);
        fstorder(p->rch);
    }
}
void lastorder(bnode *p)     /*后序递归遍历二叉树*/
{
    if(p)
    {
        lastorder(p->lch);
        lastorder(p->rch);
        printf("%c",p->data);
    }
}

}
bnode  *creat()
{
   bnode *p;
   char x; 
   scanf("%c",&x);   /*输入结点的数据域*/
   if('#'==x) 
   {p=NULL;}
   else{ 
   p=(bnode *)malloc(sizeof(bnode));
            p->data=x;           /*建立根结点*/
            p->lch=creat();   /*建立左子树*/
            p->rch=creat();
        } /*建立右子树*/
   return p;
}
int Depth(bnode *b, char x)
{    
    static int depth = 1;
    if (b!=NULL) {
        if (b->data == x) {
            Depth(b->rch, x);
            depth++;
        }
        else if(b->data > x){
        Depth(b->lch, x);
            depth++;
        }
    }
    return depth;
} 
int  D(bnode *root,char k){
    int height=0;
    if(!root)
        return 0;
    while (root){
        if(root->data==k){
            height++;
            break;
        }
        else if(root->data>k){
            height++;
            root=root->rch;
        }
        else{
            height++;
            root=root->lch;
        }
    }
    return height;
}
 
main()
{
    bnode *p;
    printf("请输入二叉树的先序遍历(“#”表示结点为空):\n");
    p=creat();
    datatype t;
    printf("请输入结点值x:\n");
    scanf("%c",&t);
    printf("%c",t);
    fstorder(p);
    printf("\n");
    printf("请输入结点值x:\n");
    scanf("%c",&t);
    printf("%d\n",D(p,t));
    printf("%d\n",Depth(p,t));
    //lastorder(p);
}

这代码有几处bug,
一是求结点层次会不准确
二是main里的第一个scanf不能输入
这bug咋改啊

img

如图