关于通讯录通过名字来删除信息,如果我先删除头节点的信息,就会出问题
求大神帮忙void deletbyname(struct telephone* head,char *name)
{
struct telephone *current;
struct telephone *pre;
int p=0;
current=head;
if(strcmp(current->name,name)==0)
{
head=current->next;
free(current);
p=1;
return;
}
while(current!=NULL)
{
if(strcmp(current->name,name)==0)
{
pre->next=current->next;
free(current);
p=1;
break;
}
pre=current;
current=current->next;
}
if(p==0)
printf("查无此人\n");
[ 本帖最后由 GreenhandG 于 2015-6-22 15:28 编辑 ]