Quote Originally Posted by pavitratandon
How to reverse a doubly link list...?? its not traversing... its reversing the whole list...
plz help
Then what's the Problem a Doubly Linked list is Something like
------------- ------------- -------------
| | | | <---+-- | | | <---+-- | | |
| 0 | a | --+---> | | b | --+---> | | c | 0 |
------------- ------------- -------------

So by taking the Pointer of tail you can traverse from tail to head hope this will help you.Here is a Simple Code just Check it out . i didn't check this code.

Example Code :-

Code:
#define PTR_XOR(a, b) (void*)( ((int)(a)) ^ ((int)(b)))
struct list_head* reverse(struct list_head* h) 
{
	if(h->next == h->prev)
		return h;

	do {
		h->prev = PTR_XOR(h->prev, h->next);
		h->next = PTR_XOR(h->prev, h->next);
		h->prev = PTR_XOR(h->prev, h->next);
		h = h->next;
	} while (h->next->prev != h);
	return h;
}