statement missing ;in function delete

来源:百度知道 编辑:UC知道 时间:2024/09/23 04:16:08
struct lib
{int num;char type[20];int max;char name[15];int use; struct lib *next;}*head,*p1,*p2;

#define null 0
#define len sizeof(struct lib)

input ( struct lib *p1)
{printf("enter the number of the room");
scanf("%d",&p1->num);
printf("\nenter the type of the room:");
scanf("%s",p1->type);
printf("\nhow many people can hold:");
scanf("d",&p1->max);
printf("\nwho? in charge :");
scanf("%s",p1->name);
printf("\nuse it(1) or not (0):");
scanf("%d",&p1->use);}

in ()
{head=null;p1=(struct lib *)malloc(len); input(p1);}

struct lib *create()
{int n=0;p1->next=null; while(p1->num!=0)
{++n; if(n==1)head=p1; else p2->next=p1;p2=p1;
p1=(struct lib *)malloc(len); input(p1);p1->next=null;}
free(p1);return(head);}

menu

delete()
{int num;
printf("which number to del");
scanf("%d",&num);
p1=head;
while(p1!=null)
{p2=p1;p1=p1->next;
if(num==p1->num)
{if(p1->use==1) printf("It used");
else if(p1==head) head=p1->next;
else {p2->next=p1->next; printf("deleted");free(p1);break;}
}
}
printf("nothing presented means it can’t be del");
}