?? 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 + -