在xianxu函数内的printf无法打印输出这是为什么?该如何解决?
#include<stdio.h>
#include<stdlib.h>
typedef struct tree
{
int date;
struct tree *left;
struct tree *right;
}tree;
int creat(tree *head);
void xianxu(tree *head);
int main()
{
tree *head;
creat(head);
xianxu(head);
}
int creat(tree *head)
{
char x;
scanf("%c",&x);
getchar();
if(x=='#')
{
head=NULL;
}
else
{
tree *ne=(tree*)malloc(sizeof(tree));
if(!head)
{
exit(-1);
}
ne->date=x;
creat(ne->left);
creat(ne->right);
}
}
void xianxu(tree *head)
{
if(head!=NULL)
{
printf("%c\n",head->date);
xianxu(head->left);
xianxu(head->right);
}
}