I want to swap two nodes of a linked list. Like if its 12 23 34 45 then i want result like 21 32 43 54..... if input is 12345 then output should be 21435. something like that...

I have written following .... but its not producing the desired output ..... somebody plz help me out

#include<stdio.h>

#include<conio.h>

#include<malloc.h>

struct list{

int roll_no; /* Storing roll number of a node */

// char name[N]; /* Storing name of node */

float marks; /* Storing marks of a node */

struct list *next; /* Storing next address */

};

/***** Redefining struct list as node *****/

typedef struct list node;

node* swap(node *current)

{

int rno; /* Roll number for swaping node*/

int t; /* Total number of nodes */

node *temp; /* Temporary copy of current */

node *tmp; /* Temporary variable */

t=number(current);

if(t<=1)

{

printf("\nYou cannot swap the only node\n");

return(current);

}

printf("\nEnter roll number whose node you want to swap with the next\n");

scanf("%d",&rno);

temp=current;

if(current->roll_no==rno)

{

tmp=current->next;

current->next=current->next->next;

tmp->next=current;

current=tmp;

return(current);

}

else

{

while(temp->next->next!=NULL)

{

if(temp->next->roll_no==rno)

{

tmp=temp->next->next;

temp->next->next=temp->next->next->next;

tmp->next=temp->next;

temp->next=tmp;

break;

}

temp=temp->next;

}

return(current);

}

}

int main()

{

head=swap(head); // head is the first node of the linked list

getch();

}