c ++:分段错误(内核已转储)

问题描述 投票:-1回答:1

我正在尝试对二叉树进行一些试验。运行以下程序时出现segmentaion fault(core dumped)

#include<iostream>

using namespace std;

struct tree{
   char data;
   tree *left=NULL;
   tree *right=NULL;
   tree *parent=NULL;
};   


tree* newNode(char d)
{
   struct tree* node;
   node->data = d;
   return node;
}
int main()
{
   struct tree* currentNode = newNode(' ');
         return 0;
}

是什么导致此错误?如何纠正呢?

c++ struct insert binary-search-tree
1个回答
0
投票

此功能

© www.soinside.com 2019 - 2024. All rights reserved.