【发布时间】:2017-08-23 15:14:32
【问题描述】:
这是我在二叉搜索树中插入项目的实现。
void insert(struct Node* root,int item){
if(root==NULL){
root = newNode(item); // newNode is a function which creates new node, initialized it with item & return pointer of the new node.
}
if(item < root->item)
insert(root->left,item);
else
insert(root->right,item);
}
但我不知道为什么它在驱动程序中进行以下调用时会出现分段错误?
struct Node* root = NULL;
insert(root,50);
【问题讨论】:
-
我建议你做一些关于在c中模拟通过引用传递的研究。
-
您是否尝试过将调试器指向您的二进制文件以查看崩溃发生的位置?
-
@MortenJensen Debugger 反复关闭 IDE。无法使用。
标签: c segmentation-fault binary-search-tree