【发布时间】:2018-05-31 01:41:35
【问题描述】:
我正在尝试从我创建的 Tree 字段中获取信息,但标题中出现错误:取消引用指向不完整类型“struct List_t”的指针
树源文件:
struct Node_t{
Element data;
char* location;
struct Node_t* son;
struct Node_t* next;
};
struct List_t{
Node head;
copyFunc copyfunc;
compareFunc compfunc;
freeFunc freefunc;
printFunc printfunc;
};
树头文件:
typedef struct Node_t* Node;
typedef struct List_t* Tree;
typedef void* Element;
应用源文件:
Tree t;
t = createTree(compareInt, copyInt , freeInt, printInt);
int* x =(int*)malloc(sizeof(int));
*x=53;
Add(t, x);
char* location;
location= t->head->location; //here I got the error
printf(location);
我该怎么办?我究竟做错了什么?
谢谢!
【问题讨论】:
-
你应该选择tour,尤其是How to Ask。
-
感谢您将实际错误消息复制到问题中。现在,请将所有需要的代码复制到问题中。这里有能干且通常乐于助人的人,他们只是拒绝关注链接。因此,您可以通过使用屏幕截图快捷方式来减少获得好答案的机会。
-
感谢您的评论@Yunnosch 我编辑了它。希望现在有意义。
-
请阅读链接minimal reproducible example,仅仅通过阅读文字来猜测概念的复杂细节是不够的。您的问题现在包含很多相关代码,但距离成为 MCVE 还很远。例如,您是否以及在何处包含您描述为“树源文件”的文件仍然不可见。知道它是编译的源文件(tree.c)还是包含的头文件(tree.h)也会很有趣,“trees source file”意味着.c。
标签: c pointers dereference