Return to Snippet

Revision: 4207
at November 6, 2007 16:24 by iTony


Initial Code
NodePtr reversed=NULL, cur=head;

while(cur!=NULL)
{
	//detach cur
	head=head->next;
	
	//link cur to reversed list
	cur->next=reversed;
	reversed=cur;

	//move cur to next node
	cur=head;

	head=reversed;
}

Initial URL

                                

Initial Description
this pointers are making me dizzy, so just for a reference i'll keep them here.

Initial Title
Reverse a Linked List

Initial Tags
c

Initial Language
C++