【发布时间】:2018-06-14 23:16:33
【问题描述】:
我正在传递一个链接列表,其中包含另一个链接列表到一个函数,但是我在从传递的双指针中取消/引用内部链接列表时遇到问题。此处push(*config->inner_linked_list... 行的编译器错误为'*config' is a pointer; did you mean to use '->'。内部主要&config->inner_linked_list 工作正常。我似乎无法确定我需要在这里使用哪种类型的 ref/deref。
typedef struct new_inner {
wchar_t setting[10];
wchar_t val[10];
struct new_inner * next;
}INTLL_t ;
typedef struct new_head {
wchar_t name[10];
struct INTLL_t * inner_linked_list;
struct new_head * next;
} HEAD_t;
// In Main
int main(){
...
HEAD_t * config;
config = malloc(sizeof(HEAD_t));
config = NULL;
//config populated elsewhere
functo1(&config);
...
}
BOOL functo1(HEAD_t ** config){
HEAD_t * current = *config;
while(current != NULL){
INTLL_t * s = another_ll; // Also INTLL_t
while(s != NULL){
push(*config->inner_linked_list, another_ll->setting,another_ll->val);
s = s->next;
}
current = current->next;
}
return TRUE;
}
【问题讨论】:
-
config = malloc(sizeof(NODE_t));你是说sizeof(HEAD_t)吗?NODE_t没有在你的代码中定义? -
我做了,已编辑。谢谢
标签: c pointers linked-list double-pointer