关于读取数据的问题
#include<stdio.h>
#include<stdlib.h>
typedef struct _BinTree
{
char data;
struct _BinTree *LeftNode;
struct _BinTree *RigthNode;
}BinTree;
BinTree BuidTree()
{
BinTree p1 = { 'A',nullptr,nullptr };
BinTree p2 = { 'B',nullptr,nullptr };
BinTree p3 = { 'C',nullptr,nullptr };
BinTree p4 = { 'D',nullptr,nullptr };
BinTree p5 = { 'E',nullptr,nullptr };
BinTree p6 = { 'F',nullptr,nullptr };
BinTree p7 = { 'G',nullptr,nullptr };
BinTree p8 = { 'H',nullptr,nullptr };
p1.LeftNode = &p2;
p1.RigthNode = &p6;
p2.RigthNode = &p3;
p3.LeftNode = &p4;
p3.RigthNode = &p5;
p6.RigthNode = &p7;
p7.LeftNode = &p8;
return p1;
}
void ForEach(BinTree *bintree)
{
if (nullptr == bintree->LeftNode && nullptr == bintree->RigthNode)
return;
//前序遍历 根左右 DLR
printf("%c\n", bintree->data);
ForEach(bintree->LeftNode);
ForEach(bintree->RigthNode);
}
void main()
{
ForEach(&BuidTree());
printf("Call Sucessfully!!!
}
大家看一看
为啥会在执行第二次递归的时候没有权限读取数据
在下这块儿基础不是很扎实,忘各位大佬指点迷津