A few days ago I made a function, which worked just fine. This is struct defining I used.
typedef struct {
int data;
struct Node * next;
} Node;
typedef struct {
Node * head;
Node * current;
int size;
} List;
Then I have this function
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);
}
}
But now I receive given error and I don't understand why? Does anyone know?
second = first->next->next;
<<< this is where I get an error message, up to here it works fine