源代码:
#include <iostream>
#include <vector>
#include <fstream>
#include <windows.h>
using namespace std;
int main()
{
vector<unsigned char> bvec;
unsigned char temp;
fstream file("D:\\a48s.EP",fstream::ate|fstream::in|fstream::out|fstream::binary);
if (!file)
{
cerr<<"error:unable to open the file."<<endl;
return 0;
}
fstream::pos_type end_mark=file.tellg();
fstream::pos_type mark;
file.seekg(0,ios::beg);
while (file.tellg()!=end_mark)
{
mark=file.tellg();
file>>temp;
bvec.push_back(temp);
}
vector<unsigned char>::size_type length=bvec.size();
return 0;
}
把一个文件读到Vector后,发现读出的数据和实际问价大小不一致,不知道什么原因?其中好像碰到二进制0c 00 就没有读到vector中,求解释。