错误:取消引用指向不完整类型的指针
Codeblocks在main.c第10行(print_bst(tree-> root))(解除引用不完整类型的指针)时给出了这个错误,而我正在创建二进制搜索树,但我找不到此错误的原因.
BST.h
typedef struct Node Node;
typedef struct Tree Tree;
Tree *create_bst();
Node *create_node(int data);
void insert_bst(Tree *tree);
void print_bst(Node *root);
Run Code Online (Sandbox Code Playgroud)
BST.c
#include <stdio.h>
#include <stdlib.h>
typedef struct Node{
void *dataPtr;
int data;
struct Node *left;
struct Node *right;
} Node;
typedef struct Tree{
int count;
Node* root;
} Tree;
Tree *create_bst()
{
Tree *tree = (Tree*) calloc(1,sizeof(Tree));
if(tree == NULL){
printf("calloc() failed!\n");
return NULL;
}
tree->count = 0;
tree->root = NULL;
return tree;
}
Node *create_node(int data) …Run Code Online (Sandbox Code Playgroud)