Possible Duplicate:
How to reverse a singly linked list using only two pointers?
This is C code to reverse a linked list. But this isn't producing the desired output.
struct node *temp,*prev;
while(head->next!=NULL)
{
temp=prev=head;
while(temp->next->next!=NULL)
{
temp=temp->next;
prev=prev->next;
}
temp=temp->next;
temp->next=prev;
prev->next=NULL;
}
What am I missing?