下面是我的C语言图书管理代码,很简陋,但是还是有一点小问题,有没有大佬帮忙看一下,
就是,写入文件没问题,读文件并输出就有问题了,麻烦各位大佬看一下谢谢
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
#include<conio.h>
struct book
{
char name[50];
char auther[30];
char ISBN[30];
char publisher[40];
int year;
int number;
float price;
struct book*p;
};
struct book shu;//结构体全局变量
void add_book();//添加图书
void search_book();//查询图书
void name();//按书名查找
void auther();//作者名查找
void ISBN();//按书的ISBN号查询
void publisher();//按出版社查找
void year();//按出版年份查找
void price();//按图书的价格
int condition=0;
int main()
{
int n;
while(condition==0)//界面
{
system("cls");
printf("*****************欢迎登陆图书信息管理系统*****************\n");
printf("***************** 1.图书录入 2.图书浏览 *****************\n");
printf("***************** 请输入您的序号 *****************\n");
scanf("%d",&n);
if(n==1)
{
add_book();
}
else if(n==2)
{
search_book();
}
else
{
system("cls");//cls为清屏操作
printf("******* 输入错误,请重新输入 ********\n");
}
}
return 0;
}
void add_book()//图书录入系统的子函数
{
system("cls");
int xx;
FILE *fp;//指针指向文件
fp=fopen("F:\\mybook\\mybook.txt","a");
if((fp)==NULL)//数据保存的文件地址
{
printf("file open error!\n");
exit(0);
}
printf("****** 请输入书名 ******\n");
scanf("%s",shu.