0
int function(struct node* head){ int var = 0; while(head->next != NULL){ var++; head = head->next; } return var; }
Can you find error in it
2 Respostas
0
Is "next" of type "pointer to node type"? If yes, are you sure the error isn't outside the function?
0
If this function counts elements in linked list, then you should change condition in loop on head != NULL, because your answer is always 1 less than actual length of linked list.