求助高手~~ 访问内存冲突(分割故障) 是什么原因造成的!!!!
struct person *del_person (struct person *head)
{
struct person *p1,*p2;
struct person0 *p;
char name[20];
int m=1;
char t;
while(m)
{
fp=fopen("tel_book.txt","rb");
if(fp=NULL){printf("the list is null\n");
exit(0);
}
else
{
p=person;
fread(p,LEN0,1,fp);
if(!feof(fp)){printf("tel_book.txt is empty file!\n");
fclose(fp);
return 0;
}
rewind(fp);
move(fp);
p1=head;
printf("\n Please input the Name for deletion:");
scanf("%s",p1->name);
while(strcmp(name,p1->name)!=0&&p1->next!=NULL)//未找到,并且后面还有结点
{
p2=p1;p1=p1->next;
}
if(strcmp(name,p1->name)==0)
{
if(p1==head)head=p1->next;//p1指向首结点,把第二个结点位置赋予head
else
{p2->next=p1->next;//将下一个结点地址赋给前一结点地址
printf("you have deleted:%s",name);
}
j--;
}
else printf("Can't find the record");
save(head);
}
fclose(fp);
printf(" continue delete?(y / n)\n");
while(getchar()!='\n');
scanf("%c",&t);
if(t!='y')m=0;
return(0);
}
}
/******************************************************************************/
我的main()函数在调用这个含函数是系统说我“访问内存冲突(分割故障) 被提出”