#include "iostream.h"
#include "string.h"
#include "stdlib.h"
#include "iomanip.h"
#include "stdio.h"
#include "process.h"
typedef struct library
{
int num;
char name[20];
char author[10];
char kind[10];
char pubunit[30];
char pubtime[20];
int price;
struct library *next;
}LRY;
LRY *createlib()
{
LRY *p,*headlib,*tail;
int num,price;
char name[20],kind[10],author[10];
char pubunit[30],pubtime[20];
int size=sizeof(LRY);
headlib=tail=NULL;
cout<<"输入图书信息:"<
cin>>num>>name>>author>>kind>>pubunit>>pubtime>>price;
while(num)
{
p=(LRY *)malloc(size);
p->num=num;
strcpy(p->name,name);
strcpy(p->author,author);
strcpy(p->kind,kind);
strcpy(p->pubunit,pubunit);
strcpy(p->pubtime,pubtime);
p->price=price;
if(headlib==NULL)
headlib=p;
else
tail->next=p;
tail=p;
cin>>num>>name>>author>>kind>>pubunit>>pubtime>>price;
}
tail->next=NULL;
return headlib;
}
void savefilelib(LRY *headlib)
{
LRY *p;
FILE *fp;
if((fp=fopen("e:\\library.txt","w"))==NULL){
cout<<"open fail!"<
exit(0);
}
fprintf(fp,"登陆号 图书名 图书作者 图书分类号 出版单位 出版日期 价格\n");
for(p=headlib;p;p=p->next)
fprintf(fp,"%4d%15s%10s%11s%18s%12s%6d\n",p->num,p->name,p->author,p->kind,p->pubunit,p->pubtime,p->price);
if(fclose(fp)){
cout<<"close fail!"<
exit(0);
}
cout<<"创建后的信息已放入E盘根目录的“library.txt”文件中"<
}
void savefilelibnew(LRY *headlib)
{
LRY *p;
FILE *fp;
if((fp=fopen("e:\\librarynew.txt","w"))==NULL){
cout<<"open fail!"<
exit(0);
}
fprintf(fp,"登陆号 图书名 图书作者 图书分类号 出版单位 出版日期 价格\n");
for(p=headlib;p;p=p->next)
fprintf(fp,"%4d%15s%10s%11s%18s%12s%6d\n",p->num,p->name,p->author,p->kind,p->pubunit,p-
图书管理系统
最新推荐文章于 2024-06-25 09:00:00 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)