?? readfile.c
字號:
#include "TypeDef.h"
#include <stdio.h>
void ReadFile(BookDbFile *bf, BnoIdxFile *bif, BnameIdxFile *bnif, BauthorIdxFile *baif, BpressIdxFile* bpif, ReaderFile *rf, BborrowFile *bbf)
{
//讀圖書主文件,書號索引鏈頭文件,書名索引鏈表文件,作者索引鏈表文件,出版社索引鏈表文件,讀者文件,讀借還書文件
FILE *fp = NULL;
int idx = 1, i = 0;
//*****讀入圖書主文件*************************
fp = fopen("BookDbFile.yangq", "r");
if(fp == NULL)
{
printf("Error : The BookDbFile.yangq is not exsit.\n");
return;
}
while(!feof(fp))
{
fscanf(fp, "%d", &idx);
fscanf(fp, "%s%s%d%s%d%s%d%s%d%d",
bf->BookDbase[idx].bno,
bf->BookDbase[idx].bname,
&bf->BookDbase[idx].namenext,
bf->BookDbase[idx].author,
&bf->BookDbase[idx].authnext,
bf->BookDbase[idx].press,
&bf->BookDbase[idx].prenext,
bf->BookDbase[idx].sortno,
&bf->BookDbase[idx].storenum,
&bf->BookDbase[idx].borrownum);
i++;
}
bf->len = i;
fclose(fp);
//*******************************************
//*****讀入書名索引文件***********************
i = 0;
fp = NULL;
fp = fopen("BnameIdxFile.yangq", "r");
if(fp == NULL)
{
printf("Error : The BnameIdxFile.yangq is not exsit.\n");
return;
}
while(!feof(fp))
{
fscanf(fp, "%s%d%d", bnif->BnameIdx[i].bname, &bnif->BnameIdx[i].head, &bnif->BnameIdx[i].RecNum);
i++;
}
bnif->len = i;
fclose(fp);
//*******************************************
//*****讀入作者索引文件**********************
i = 0;
fp = NULL;
fp = fopen("BauthorIdxFile.yangq", "r");
if(fp == NULL)
{
printf("Error : The BauthorIdxFile.yangq is not exsit.\n");
return;
}
while(!feof(fp))
{
fscanf(fp, "%s%d%d", baif->BauthorIdx[i].author, &baif->BauthorIdx[i].head, &baif->BauthorIdx[i].RecNum);
i++;
}
baif->len = i;
fclose(fp);
//*******************************************
//*****讀入出版社索引文件********************
i = 0;
fp = NULL;
fp = fopen("BpressIdxFile.yangq", "r");
if(fp == NULL)
{
printf("Error : The BpressIdxFile.yangq is not exsit.\n");
return;
}
while(!feof(fp))
{
fscanf(fp, "%s%d%d", bpif->BpressIdx[i].press, &bpif->BpressIdx[i].head, &bpif->BpressIdx[i].RecNum);
i++;
}
bpif->len = i;
fclose(fp);
//*******************************************
//*****讀入讀者文件**************************
i = 0;
fp = NULL;
fp = fopen("ReaderFile.yangq", "r");
if(fp == NULL)
{
printf("Error : The ReaderFile.yangq is not exsit.\n");
return;
}
while(!feof(fp))
{
fscanf(fp, "%s%s%d%d", rf->ReadRec[i].rno, rf->ReadRec[i].name, &rf->ReadRec[i].bn1, &rf->ReadRec[i].bn2);
i++;
}
rf->len = i;
fclose(fp);
//********************************************
//*****讀入書號索引文件***********************
i = 0;
fp = NULL;
fp = fopen("BnoIdxFile.yangq", "r");
if(fp == NULL)
{
printf("Error : The BnoIdxFile.yangq is not exsit.\n");
return;
}
while(!feof(fp))
{
fscanf(fp, "%d%s", &bif->BnoIdx[i].RecNo, bif->BnoIdx[i].bno);
i++;
}
bif->len = i;
fclose(fp);
//*******************************************
//*****讀入借還書文件************************
i = 0;
fp = NULL;
fp = fopen("BborrowFile.yangq", "r");
if(fp == NULL)
{
printf("Error : The BborrowFile.yangq is not exsit.\n");
return;
}
while(!feof(fp))
{
fscanf(fp, "%s%s%s%s",
bbf->Bbook[i].rno,
bbf->Bbook[i].bno,
bbf->Bbook[i].date1,
bbf->Bbook[i].date2);
i++;
}
bbf->len = i;
fclose(fp);
//*******************************************
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -