swap alternate nodes in a linked list

I was trying to do this [question][1] on geeks for geeks. Can someone please tell me what is wrong with my code:

void pairWiseSwap(struct node *head)
{
   if(head==NULL||head->next==NULL)
   return;
   node *i,*j,*tf,*prev;
   i=head;
   j=i->next;
   head=j;
   prev=NULL;
   while(j!=NULL)
   {
       if(prev==NULL)
       {
           tf=j->next;
           j->next=i;
           i->next=tf;
       }
       else
       {
           tf=j->next;
           j->next=i;
           i->next=tf;
           prev->next=j;
       }
       prev=i;
       i=tf;
       if(i==NULL)
       break;
       j=i->next;
   }
}

I am trying to swap nodes instead of their data.
Any suggestion :slight_smile:
[1]: https://www.geeksforgeeks.org/pairwise-swap-elements-of-a-given-linked-list/

The problem is I don’t have any information about the main function. This is just a function problem as given in the link above. Also I am handling the corner cases but I can’t find a way to update head.
Thanks for your help:)

OK.THANKS FOR YOUR TIME SIR:)

Welcome @pavitra_ag sir. Happy Coding :slight_smile: