求助高手~~ 访问内存冲突(分割故障) 是什么原因造成的!!!!

sj307639429 sj307639429 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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()函数在调用这个含函数是系统说我“访问内存冲突(分割故障) 被提出”
...全文

相关推荐

评论 20
收藏 已收藏
分享
返回顶部
sj307639429
C语言 70,040 成员 243,237 内容