如何以字节形式读取文件,而不是使用矢量。从文件中逐字节读取
通过使用这个,我可以读取整个文件成一个字节的矢量。
std::basic_ifstream<BYTE> file(driveName, std::ios::binary);
vector<BYTE> x = std::vector<BYTE>(
(std::istreambuf_iterator<BYTE>(file)),
std::istreambuf_iterator<BYTE>());
不过,我想先读512个字节,那么“X”个字节,“X1”字节等, 容量调整选项犯规在这里工作。
我看到这个链接,reading the binary file into the vector of unsigned chars,这造成了更多的困惑。
任何帮助,将不胜感激。
也许这可以给一个想法:http://stackoverflow.com/questions/5513532/reading-binary-istream-byte-by-byte/8574393 – codeling
已经访问的帖子.. couldnt从它收集很多 –