void reverse(node *pointer) {
node *head, *curr;
head = pointer;
curr = head;
while (head != NULL) {
while (curr -> next != NULL) {
curr = curr -> next;
}
printf("%d", curr -> data);
free(curr);
curr = head;
}
}
I don't know what's wrong with the code it prints only the last node of the linked list while trying to reverse it.