C语言的程序运行问题,帮忙看看,为什么编译没有错误,却一运行就崩溃?

#include<stdio.h>structbooks{charname[100];intnumber;floatprice;charauthor[100];intst... #include <stdio.h>
struct books
{
char name[100];
int number;
float price;
char author[100];
int state;
char student;
int sex;
int studentnumber;
}book[10];
int i,x,j,n;

table()
{
printf(" **************************************************\n");
printf(" 欢迎使用图书管理系统 \n");
printf(" 请选择你所想执行的功能 \n");
printf(" 1.输入新进书籍信息 \n");
printf(" 2.查询图书 \n");
printf(" 3.删除图书信息 \n");
printf(" 4.借书 \n");
printf(" 5.还书 \n");
printf(" **************************************************\n");
}

putin()
{
FILE *fp;
fp=fopen("book.txt","w+");
for(i=0;i<=10;i++)
fscanf(fp,"%s,%d,%f,%s,%d,%s,%d,%d",book[i].name,&book[i].number,&book[i].price,book[i].author,&book[i].state,book[i].student,book[i].sex,book[i].studentnumber);
scanf("%d",x);
scanf("%s,%d,%f,%s,%d,%s,%d,%d",book[i].name,&book[i].number,&book[i].price,book[i].author,&book[i].state,book[i].student,book[i].sex,book[i].studentnumber);
for(i=0;i<=10;i++)
fprintf(fp,"%s,%d,%f,%s,%d,%s,%d,%d",book[i].name,&book[i].number,&book[i].price,book[i].author,&book[i].state,book[i].student,book[i].sex,book[i].studentnumber);
fclose(fp);
}

search()
{
FILE *fp;
fp=fopen("book.txt","a+");
scanf("%d",&i);
for(x=0;x<=i;x++)
fscanf(fp,"%s,%d,%f,%s,%d,%s,%d,%d",book[i].name,&book[i].number,&book[i].price,book[i].author,&book[i].state,book[i].student,book[i].sex,book[i].studentnumber);
fclose(fp);
if(book[x].state==0)
printf("%s,%d,%f,%s,此书现藏于馆中",book[i].name,&book[i].number,&book[i].price,book[i].author);
else
if(book[x].sex==1)
printf("%s,%d,%f,%s,已借出,%s,girl,%d",book[i].name,&book[i].number,&book[i].price,book[i].author,book[i].student,book[i].studentnumber);
else
printf("%s,%d,%f,%s,已借出,%s,boy,%d",book[i].name,&book[i].number,&book[i].price,book[i].author,book[i].student,book[i].studentnumber);
}

main ()
{
table();
scanf("%d",n);
switch(n)
{
case 1:putin();
break;
case 2:search();
break;

}
return 0;
}
展开
 我来答
百度网友2018359
2016-12-23 · TA获得超过3494个赞
知道大有可为答主
回答量:3486
采纳率:73%
帮助的人:1455万
展开全部
数组越界了
改为: for(i=0;i<10;i++)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式