📄 match.cpp
字号:
//***************************************************
// 匹配
// 即浏览文件查看是否存在用户要查找的书
// 存在返回非0, 不存在返回0
//***************************************************
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<string.h>
#include"book.h"
int match(char *s)
{
fstream file("book.dat",ios::in|ios::binary);
if(!file)
{
cout<<"\n\t\t打开文件失败!"<<endl;
exit(1); //意外终止程序运行
}
book temp;
int n=0;
while(!file.eof())
{
file.read((char*)&temp,sizeof(temp));
if(strcmp(s,temp.getbookname())==0)
n++;
}
file.close();
return n; //实际返回的是与书名相同书的种类数
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -