【小白求助】我这个二叉树输入为什么出错,找不出错误
程序代码:
#include <stdio.h> #include <stdlib.h> typedef char ElemType; typedef struct BiTNode { char date; struct BiTNode *lchild, *rchild; }BiTNode, *BiTree; CreateBiTree(BiTree *T) { char c; scanf("%c",&c); if('#'== c) { *T= NULL; } else { *T=(BiTNode *)malloc(sizeof(BiTNode)); (*T)->date = c; CreateBiTree(&(*T)->lchild); CreateBiTree(&(*T)->rchild); } } visit(char c) { printf("%c",&c); } PreDrderTraverse(BiTree T) { if(T) { visit(T->date); PreDrderTraverse(T->lchild); PreDrderTraverse(T->rchild); } } int main() { BiTree T = NULL; CreateBiTree(&T); PreDrderTraverse( T ); return 0; }