void reverse(LIST **head)
{
if(!*head)
return ;
LIST *first=*head,*rest=(*head)->next;
if(!rest)
return;
reverse(&rest);
first->next->next = first;
first->next= NULL;
*head = rest;
// printf(" :%d",rest->data);
}
This program is working. The mentioned recursive code is for reversing the singly linked list.Consider a list L={1,2,3,4,5} as input.Consider two cases, case 1 if we uncomment statement 10, output will be data of last node i.e. 5 four times, case 2 if we comment statement no. 09 then the printf will print 5,4,3,2. My question is, in case 1 due to this statement *head=rest; why we get constant value for rest->data each call of function? If we removed statement no. 09 then printf will print different values of rest->data.
Thank you so much in advance.