![](https://csdnimg.cn/release/download_crawler_static/87802232/bg4.jpg)
.
把信息存入 txt.txt 文件
关闭录入信息的文件
结束
图书录入流程图
【程序】
void input() /*定义录入函数*/
{
int i;
BOOK a;
FILE *fp;
if((fp=fopen("txt.txt","w"))==NULL)
{
printf("error!\n");exit(0);
}
for(i=1;i<=N;i++)
{
printf("\t 请输入您所需书籍的登陆号:");
scanf("%ld",&a.num);
printf("\t 请输入书名:");
scanf("%s",a.name);
printf("\t 请输入作者名:");
scanf("%s",a.writer);
printf("\t 请输入分类号:");
scanf("%s",a.sort);
printf("\t 请输入出版单位:");
scanf("%s",a.publisher);
printf("\t 请输入出版时间:");
scanf("%ld",&a.time);
printf("\t 请输入该书的价格:");
scanf("%f",&a.price);
fwrite(&a,sizeof(BOOK),1,fp);
}
fclose(fp);
}
《4》【图书信息浏览】
Word 专业资料