几天前我做了一个功能,效果很好。这是我使用的结构定义。
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;<<< 这是我收到错误消息的地方,到这里它工作正常