c语言问题 二叉树结构。怎么让建立节点结束,我输入的时候一直循环不能结束。

#define LEN sizeof(struct tree)
#define NULL 0
#include<malloc.h>
struct tree
{
char data;
struct tree*lchild,*rchild;
};
struct tree*creat()
{
char c;
struct tree*t;
scanf("%c",&c);
if(c=='#') t=NULL;
else
{
t=(struct tree*)malloc(LEN);
t->data=c; t->lchild= creat( );
t->rchild= creat( );
}
return t;
}
void print (struct tree*t)
{if(t!=NULL) <br>{ <br>print(t->lchild); <br>print(t->rchild); <br>printf("%c",t->data) ; <br>}
} main()
{ struct tree*t ;
t=creat();
print(t);
system("pause");
}

你好,输入的时候不能输入空格和enter,比如一次输入abc#d##e##fg##h## 才可以。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-01-11
令最后一个节点指向NULL