64,684
社区成员
发帖
与我相关
我的任务
分享
// 手写,不保证完全没错~~~
ifstream inFile;
inFile.open("dbfile.db", ios::in | ios::binary);
if (!inFile.is_open())
{
return EXIT_FAILURE;
}
inFile.seekg(0, ios::end);
int iFileSize = inFile.tellg();
// copy binary data to buffer, then use the data in buffer.
BYTE *pBuffer = new BYTE[iFileSize];
inFile.seekg(0, ios::beg);
inFile.read(pBuffer, iFileSize);
inFile.close();
// your code to use buffer data ...
delete []pBuffer;
return 0;
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char fmt,buf[100];
ifstream stream("dbfile.db");
while(!stream.eof())
{
stream.get(fmt);
stream.getline(buf,100);
if(fmt == 0x0)
printf("format is 00.\n");
else if(fmt == 0x01)
printf("format is 01.\n");
else if(fmt == 0x02)
printf("format is 02.\n");
else
printf("not format.\n");
printf("the data is:%s\n",buf);
}
stream.close();
return 0;
}