#include
#include
#include
#include
struct abcd
{ char accession_number[30];
char title[30];
char author[30];
char class_number[30];
char publish_unit[30];
char publish_time[30];
char price[30];
};
void add();
void referall();
void referone();
void myprintf();
void del();
void change();
void add()
{
FILE *fp;int i=0,m=0;char ch,yes1no='\0';
struct abcd question[100];
do{
fflush(stdin); /*清除缓存区函数*/
system("cls"); //清屏函数
printf("输入格式是:\n");
printf("登录号是:TP391.41/4008/8 \n");
printf("书名是: photshopcs\n");
printf("作者名是:东方人华 \n");
printf("分类号是:ps\n");
printf("出版单位是:清华大学出版社\n");
printf("出版时间是: 2005.05.01\n");
printf("价格是:35.00 \n");
printf("\n\n\n按任意键进入输入页面...");
fflush(stdin);
scanf("%c",&ch);
system("cls");
printf("请输入图书的信息(数目少于100):\n");
printf("登录号是:");
fscanf(stdin,"%s",question[i].accession_number);
printf("书名是:");
fscanf(stdin,"%s",question[i].title);
printf("作者名是:");
fscanf(stdin,"%s",question[i].author);
printf("分类号是:");
fscanf(stdin,"%s",question[i].class_number);
printf("出版单位是:");
fscanf(stdin,"%s",question[i].publish_unit);
printf("出版时间是:");
fscanf(stdin,"%s",question[i].publish_time);
printf("价格是:");
fscanf(stdin,"%s",question[i].price);
if((fp=fopen("B.txt","a"))==NULL)
{printf("file cannot be opened\n");
exit(1);
}
fprintf(fp,"%s %s %s %s %s %s %s\n",question[i].accession_number,question[i].title,question[i].author,question[i].class_number,question[i].publish_unit,question[i].publish_time,question[i].price);
printf("\n信息添加成功! \n\n",i+1);
printf("要继续添加吗(y/n)?\n");
i++;
do
{
yes1no=getch();
}while(yes1no!='y'&&yes1no!='Y'&&yes1no!='n'&&yes1no!='N');
}while(yes1no=='Y'||yes1no=='y');
fclose(fp);
}
void referall()
{
fflush(stdin); /*清除缓存区函数*/
system("cls"); //清屏函数
FILE *fp1;char ch,ch1;
if((fp1=fopen("B.txt","r"))==NULL)
{printf("file cannot be opened\n");
exit(1);
}
while((ch=fgetc(fp1))!=EOF)
fputc(ch,stdout);
fclose(fp1);
printf("\n\n\n按任意键继续...");
ch1=getchar();
system("cls");
}
void referone()
{ fflush(stdin); /*清除缓存区函数*/
struct abcd question1[100];
FILE *fp2;int i=0,j,z,m=0;char list1[30];char ch;
if((fp2=fopen("B.txt","r"))==NULL)
{
printf("file cannot be opened\n");
exit(1);
}
while(!feof(fp2))
{fscanf(fp2,"%s%s%s%s%s%s%s\n",question1[i].accession_number,question1[i].title,question1[i].author,questio
n1[i].class_number,question1[i].publish_unit,question1[i].publish_time,question1[i].price);
i++;
}
fclose(fp2);
printf("\n请输入你要查看的图书的登录