I am trying to read a binary file into an array of unsigned 32-bit integers. However, I am experiencing some problems with endianness, as my input is reversed in groups of 8 bits (e.g. 0x65206669
becoming 0x69662065
). This is how I read the file:
std::ifstream input;
input.open(filename.c_str(), std::ios::in | std::ios::binary);
if (!input.is_open()) return false;
uint32_t buffer[262144];
input.read((char*)buffer, 1048576);
Do I need to convert the buffer's endian, or is there some function which can read a binary file into integers?