最近在学习二叉树的时候遇到一个疑惑的现象
明明是相同的输入,只是多了几个Enter,程序就不会结束了,哪位好心解答一下呗。
附源代码
#include <stdio.h>
#include <malloc.h>
typedef char ElemType;
typedef struct BiNode
{
ElemType data;
struct BiNode *lchild ,*Rchild;
}BiTNode,*BiTree;
void create(BiTree &T)
{
ElemType Val;
BiTNode *p=(BiTNode *)malloc(sizeof(BiTNode));
scanf("%c",&Val);
if(Val!='#'){
p->data=Val;
create(p->lchild);
create(p->Rchild);}
else
p =NULL;
T=p;
}
int main()
{ BiTree T=NULL;
create(T);
return 0;
}