Here is the answer! :-)
void reverse(LIST **head)
{
01: if(!*head)
02: return ;
03: LIST *first=*head,*rest=(*head)->next;
04: if(!rest)
05: return;
06: reverse(&rest); //head pointer in new function call context is a rest pointer in previous function call context.
07: first->next->next = first;
08: first->next= NULL;
09: *head = rest;
10: // printf(" :%d",rest->data);
}
What is happening here is every time function call is returned, "*head = rest;" this statement is updating the value at location *head(which is address of head pointer) with address of rest pointer, which has effect throughout in program execution context. Every time function call returns head pointer is updated, means in every previous call rest pointer is updated (refer line 6 comment).