We can reverse the linklist elements by adjusting the node references only. That is, change the fist node into last.
node *rev(node *l)
{
node *temp1,*temp2,*temp3;
int c=1;
temp1=l;
temp2=l;
do
{
temp3=temp2->next;
if(c==1)
{
temp2->next=NULL;
temp2=temp3;
temp3=temp3->next;
}
else
{
temp2->next=temp1;
temp1=temp2;
temp2=temp3;
temp3=temp3->next;
}
c++;
}while(temp3!=NULL);
temp2->next=temp1;
return temp2;
}