vector<byte> h;
ifstream fin(file.c_str(), ios::binary);
if(!fin)
return false;
byte b;
while(fin >> b)
h.push_back(b);
The length of h is 4021, while the raw file length is 4096 bytes. But the code below gives a string of 4096 bytes. Why?
ostringstream sout;
sout << fin.rdbuf();
string s = sout.str();
UPDATES:
@user2079303 solved my problem, but any other way to perform the reading task. It's too easy to get it wrong.
fin.tellg()to output the current position. Find out that when I got the the 2000 bytes, the vector length is 1995.bytetype come from?windows.hmaybe defined a micro like#define unsigned char byte. I'm programming using win32.