#include <iostream>
#include <fstream>
#include <vector>
#include <cstdio>
#include <algorithm>
int main()
{
const char path[] = { "hoge.dat" };
std::vector<char> buffer(1024 * 1024); // 1MB
std::ofstream f(path, std::ios::binary);
for (int gb = 0; gb < 5; ++gb) {
std::fill(buffer.begin(), buffer.end(), static_cast<char>(gb));
for (int i = 0; i < 1024; ++i) f.write(buffer.data(), buffer.size());
}
f.close();
#pragma warning(suppress : 4996)
std::FILE* fp = std::fopen(path, "rb");
for (int i = 0; i < 5 * 1024; ++i) {
if (std::fread(buffer.data(), sizeof(buffer[0]), buffer.size(), fp) < buffer.size()) return 1;
for (auto ch : buffer) if (ch != static_cast<char>(i / 1024)) return 2;
}
std::fclose(fp);
std::cout << static_cast<int>(buffer[buffer.size() - 1]) << std::endl;
return 0;
}
とりあえずVC++2019でx86(32bit)ビルドして実行したら終了コード0の出力4だったのでfread 4GBは超えられてる模様