On Dec 3, 4:36 pm, ratika <cool_ratikagu. ..@rediff.comwr ote:
can anyone tell me how to delete a certain node in a doubly circular
link list
//circular doubly link list
#include<stdio. h>
#include<conio. h>
#include<alloc. h>
struct node
{
struct node *pre;
int data;
struct node *next;
};
void addnode(struct node** , int);
void display(struct node*);
void delfirst(struct node*);
void main()
{
int item,ch;
struct node **t;
clrscr();
*t=NULL;
do
{
printf("\nMenu: \n1.add node\n2.display \n3.delete first node\n4.exit
\nenter the choice");
scanf("%d",&ch) ;
switch(ch)
{
case 1:
printf("enter the value to be inserted");
scanf("%d",&ite m);
addnode(t,item) ;
break;
case 2:
display(*t);
break;
case 4:
break;
case 3:
delfirst(*t);
break;
default:
printf("wrong choice try again");
}
}while(ch!=3);
getch();
}
//functions starts
void addnode(struct node **t,int val)
{
struct node *temp,*temp1;
temp=(struct node*)malloc(si zeof(struct node));
temp->pre=NULL;
temp->data=val;
temp->next=NULL;
if(*t==NULL)
{
*t=temp;
temp->pre=*t;
temp->next=*t;
}
else
{
*t=temp1;
while(temp1->next!=*t)
{
temp1=temp1->next;
}
temp1->next->pre=temp;
temp->next=temp1->next;
temp->pre=temp1;
temp1->next=temp;
}
}
void display(struct node *t)
{
struct node *temp;
if(t==NULL)
{
printf("link list empty");
}
else
{
temp=t;
while(temp->next!=NULL)
{
printf("%d",tem p->data);
temp=temp->next;
}
}
}
void delfirst(struct node *st)
{
if(st==NULL)
{
printf("link list empty");
}
else
{
struct node *temp;
temp=st;
temp->pre->next=temp->next;
st=temp->next;
temp->next->pre=temp->pre;
}
}
this is the program made by me please see and tell me the errors