Код: Выделить всё
dump.cc
Код: Выделить всё
#include
#include
#include
#include
std::vector ReadFile(const std::string &filename) {
FILE *file = fopen(filename.c_str(), "rb");
if (file == NULL) {
throw std::runtime_error("Error opening file: " + filename);
}
fseek(file, 0L, SEEK_END);
size_t file_size = ftell(file);
rewind(file);
std::vector buffer(file_size);
size_t bytes_read = fread(buffer.data(), 1, file_size, file);
if (bytes_read != file_size) {
fclose(file);
throw std::runtime_error("Error reading file: " + filename);
}
fclose(file);
return buffer;
}
int main(int argc, char **argv) {
if (argc != 2) {
std::cerr
Подробнее здесь: [url]https://stackoverflow.com/questions/78487231/why-does-od-and-my-c-code-read-in-a-different-endianness-than-what-is-rendered[/url]