linklistreverse - the //previous one pCur= front;...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Reversing a linked list Each node in a list called “front “ contains one integer value. We want to reverse the order of the integers in another list called “ second ” . printf("\n items in list front \n "); pCur = front; while ( pCur !=NULL) { printf("%d ", pCur->data); pCur=pCur->next; } // Reverse the list by inserting every element in front of
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: the //previous one pCur= front; while(pCur !=NULL) { struct node* pNew = (struct node*) (malloc(sizeof(struct node))); pNew ->data = pCur ->data; pNew->next = second; second = pNew; pCur = pCur->next; } pCur = second; printf("\n items in list after reversing\n "); while ( pCur !=NULL) { printf("%d ", pCur->data); pCur=pCur->next; }...
View Full Document

This document was uploaded on 06/12/2011.

Page1 / 2

linklistreverse - the //previous one pCur= front;...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online