فقط نميدونم چرا ليست رو نشون نمي ده
اگه درستش كنيد ممنون ميشم
#include <stdio.h>
#include <conio.h>
#include <alloc.h>
#include <string.h>
struct st
{
char name[20];
struct st *next;
struct st *prev;
};
struct st *start;
struct st *last;
void enter();
void list();
void del();
struct st *find(char *);
int main()
{
char ch;
ch='a';
start=last=NULL;
while(ch!=4)
{
printf("enter your choice:");
ch=getche();
switch(ch)
{
case'1':
enter();
break;
case'2':
list();
break;
case'3':
del();
break;
case'4':
break;
}
}
getch();
return 0;
}
//***************************
void enter()
{
struct st *s;
char *name;
clrscr();
s=(struct st *)malloc(sizeof(struct st));
printf("enter a name:");
gets(s->name);
}
//********************************
void del()
{
struct st *t;
char name[30];
gets(name);
t=find(name);
if(t==NULL)
printf("not found");
if(t)
if(start==t)
{
start=t->next;
if(start)
start->prev=NULL;
else
last=NULL;
}
else
{
t->prev->next=t->next;
if(t!=last)
t->next->prev;
}
free(t);
printf("name deleted.");
}
//***********************
struct st *find(char *name)
{
struct st *p;
p=start;
while(p!=NULL)
{
if(strcmp(name,p->name)==0)
return p;
p=p->next;
}
return NULL;
}
//*******************************
void list()
{
struct st *r;
r=start;
clrscr();
while(r!=NULL)
{
r=r->next;
printf("%s",r->name);
}
}