Reversing a singly linked list in C [duplicate]
问题 This question already has answers here : Closed 7 years ago . 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? 回答1: You don't provide enough informations to have more