How to read C++ binary file into a buffer (C++17 way)
#include <iostream>
#include <fstream>
#include <filesystem>
// Get size of file to know how much memory to allocate
std::uintmax_t filesize = std::filesystem::file_size("C037B221110.bin");
// Allocate buffer to hold file
char* buf = new char[filesize];
// Read file
std::ifstream fin("C037B221110.bin", std::ios::binary);
fin.read(buf, filesize);
if(!fin) {
std::cerr << "Error reading file, could only read " << fin.gcount() << " bytes" << std::endl;
}
// Close file
fin.close();