Lately I\'ve been asked to write a function that reads the binary file into the std::vector
where BYTE
is an unsigned char
std::ifstream stream("mona-lisa.raw", std::ios::in | std::ios::binary);
std::vector contents((std::istreambuf_iterator(stream)), std::istreambuf_iterator());
for(auto i: contents) {
int value = i;
std::cout << "data: " << value << std::endl;
}
std::cout << "file size: " << contents.size() << std::endl;