struct list_node {
int value;
struct list_node *next;
};
struct linked_list {
int size;
struct list_node *head;
};
void print_linked_list(struct linked_list *list){
struct linked_list *current = list;
while(current != NULL){
printf("%d ", current->head->value);
current = current->head->next;
}
}
I have to define a function to print out a linked list, but I get an error message saying "incompatible pointer type". I know that the problem is in "current = current->head->next;" but how can I achieve that?
struct list_node *curr = list->head;in place ofstruct linked_list *current = list;, and consequential changes in the loop (while (curr != NULL) { printf("%d ", curr->value); curr= curr->next; }).