⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchname.cpp

📁 该程序实现了用文件记录变长字节流
💻 CPP
字号:
#include<iostream.h>
#include<fstream.h>
#include<stdlib.h>
#include<iomanip.h>
#include<string.h>
#include"index.h"
index searchname(char *p,index &a)
{fstream f1(p,ios::in|ios::out|ios::binary);
if(!f1)
{cerr<<"exit error!"<<endl;
exit(1);
}
index c={-1,"nulltag",2};
f1.seekg(0,ios::end);
int total=f1.tellg()/d1;
index *A=new index[total];
f1.seekg(0,ios::beg);
f1.read((char *)A,total*d1);
for(int i=0;i<total;i++)
{if (strcmp(A[i].name,a.name)==0&&A[i].deletetag==0)
c=A[i];
if(strcmp(A[i].name,a.name)>0)
break;
}
if(c.key==-1) cout<<"not such element!"<<endl;
else cout<<c.key<<" "<<c.name<<endl;
return c;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -