Wednesday, July 30, 2008

C Source code for reversing a singly linked list.

void reverse(node **head) {

node *current = *head;
node *result = 0;
node *next;
while (current != 0) {

next = current->next;
current->next = result;
result = current;

current = next;
}
*head = result;
}

No comments:

Your Title