[英]Dereferencing pointer to incomplete type (struct node)
我正在使用C編寫一個簡單的AVL樹實現。我的代碼在各個部分都有問題。 有時我會收到此錯誤,有時取消引用的效果很好。
這是我的結構節點的外觀:
struct Node
{
int data;
struct Node *left;
struct Node *right;
int height;
};
這是我得到解引用錯誤的地方(確切地是if(data <(p-> data)) )
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;
}
任何幫助,將不勝感激。 謝謝
將struct node
更改為struct Node
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.