这里的删除是什么意思?
手机的通讯簿中有5个人的信息,每个人的信息由位置号、姓名和电话号码3部分组成,编写程序输入不再联系的人员姓名,删除该人的信息。
#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct student)
struct student
{
char num[6];
char name[8];
int pnumber;
struct student *next;
}stu[10];
int main()
{
struct student *p,*pt,*head;
int i,length,flag=1;
int find=0;
char phonever;
while(flag==1)
{
printf("input length of list(<10):");
scanf("%d",&length);
if(length<10)
flag=0;
}
for(i=0;i<length;i++)
{
p=(struct student * ) malloc(LEN);
if(i==0)
head=pt=p;
else
pt->next=p;
pt=p;
printf("No.:");
scanf("%s",p->num);
printf("name:");
scanf("%s",p->name);
printf("pnumber:");
scanf("%d",&p->pnumber);
}
p->next=NULL;
p=head;
printf("n No. name pnumbern");
while(p!=NULL)
{
printf("%4s%8s%6dn",p->num,p->name,p->pnumber);
p=p->next;
}
printf("input name:");
scanf("%d",&phonever);
pt=head;
p=pt;
if(strcmp(pt->name,phonever)==0)
{
p=pt->next;
head=pt=p;
find=1;
}
else
pt=pt->next;
while(pt!=NULL)
{
if(strcmp(pt->name,phonever)==0)
{
p->next=pt->next;
find=1;
}
else
p=pt;
pt=pt->next;
}
if(!find)
printf("not found %d.",phonever);
p=head;
printf("n No. name pnumbern");
while(p!=NULL)
{
printf("%4s%8s",p->num,p->name);
printf("%6dn",p->pnumber);
p=p->next;
}
}
在输入不再联系人姓名时崩溃