2017-01-14 60 views
1

我正在使用C编写一个简单的AVL树实现。我在我的代码的各个部分遇到问题。有时我会遇到这个错误,有时候解引用工作得很好。解除引用指向不完整类型的指针(结构节点)

这是我结构节点的样子:

struct Node 
{ 
    int data; 
    struct Node *left; 
    struct Node *right; 
    int height; 
}; 

这里就是我得到的间接引用误差(准确的如果(数据<(P->数据))

struct node* search(struct node* p, int data) 
{ 
    if (!p) 
     return NULL; 
    if (data < (p->data)) 
     return search(p -> left, data); 
    else if (data > p -> data) 
     return search(p -> right, data); 
    else 
     return p; 
} 

另外这里:

struct Node remove_min(struct Node *x) 
{ 
if (x->left == NULL) 
    return x->right; 
x->left = deleteMin(x->left); 
return x; 
} 

任何帮助,将不胜感激。谢谢

+0

是'struct节点'定义和代码,你在同一个文件中看到这个错误?如果没有,你能更清楚地了解你的代码是如何组织的,你的'#include'语句是什么样的?理想情况下,您可以提供一个简单的复制器,完全展示问题。 – larsks

+0

你的代码在哪里,当你打电话搜索时,我的意思是你的主代码? –

+0

我已经发布完整的代码作为答案,您可以在那里看看,谢谢。 –

回答

2

更改struct nodestruct Node

相关问题