【发布时间】:2020-06-01 11:44:04
【问题描述】:
几天前我做了一个功能,效果很好。这是我使用的结构定义。
typedef struct {
int data;
struct Node * next;
} Node;
typedef struct {
Node * head;
Node * current;
int size;
} List;
那我就有这个功能了
void returnMiddle(List * list){
Node * first = list->head;
Node * second = list->head;
if(list->head != NULL){
while(second != NULL && second->next != NULL){
first = first->next;
second = first->next->next;
}
printf("Middle is: %d", first->data);
}
}
但是现在我收到给定的错误,我不明白为什么?有人知道吗?
second = first->next->next;
【问题讨论】:
-
struct Node不是Node。 -
我使用完全相同的不同功能,效果很好。我用了
Node * p = list->head;,一切都很好。
标签: c struct declaration typedef definition