hello
i want to build a function which receives a pointer to a head of linked list
reverses the order of the list and returns a pointer to the new head.
my list is defined like this :
typedef struct item {
int key ;
struct item *next ;
} item ;
my fucction is :
void swapitem ( item *a ) {
(a -> next) -> next = a ;
a -> next = NULL ;
} // end swapitem
item** revList ( item *head ) {
item **p ;
if ( !head -> next ) {
**p = *head ;
return p ;
}
else {
revList (head->next) ;
swapitem (head) ;
return p ;
}
} // end revList
at first when i print the list it is ok
when i try to print the list after the function it shows nothing
please advice.