Here is my sample code... plz plz somebody help me with it... the error i am getting is for the function swap and i just need 2 call that....
thanx a lot
Code:
#include<stdio.h>
#include<conio.h>
struct list{
int t1; /* Storing roll number of a node */
struct list *next, *head; /* Storing next address */
};
/***** Redefining struct list as node *****/
typedef struct list node;
void main()
{
node *head;
head*= void swap(head);
getch();
}
node* swap(node *current)
{
int t; /* Total number of nodes */
int rno;
node *temp; /* Temporary copy of current */
node *tmp;
node *roll_no; /* Temporary variable */
t=number(current);
if(t<=1)
{
printf("\nYou cannot swap the only node\n");
return(current);
}
printf("\nEnter number whose node you want to swap with the next\n");
scanf("%d",&rno);
temp=current;
if(t==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->t==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);
}
}