I've used the code below to read a binary file (in my case .docx file) and storing it in unsigned char array instead of just char (took reference from here Reading and writing binary file)
#include <fstream>
#include <iterator>
#include <vector>
int main()
{
std::ifstream input("C:\\test.docx", std::ios::binary);
std::vector<unsigned char> buffer((std::istreambuf_iterator<unsigned char>(input)),
(std::istreambuf_iterator<unsigned char>()));
}
Now I got two questions.
First thing I wanna know, is this a correct way to read a .docx file in an unsigned char array? Or are there better options available?
Secondly, I need to print the contents of file that are read in the unsigned char array, just to verify if it has correctly read the file or not. How can that be achieved?