I want to extract an unsigned integer from a binary file.
Here is the code I wrote:
std::ifstream is(path, std::ios::in|std::ios::binary);
uint32_t count;
is.read((char*)&count, 4);
std::cout << count << std::endl;
The beginning of the file is 00 00 EA 60
, and so I should get 60000
.
Instead of that, I get 1625948160
, which is 60 EA 00 00
.
EDIT:
I am asking if there is a way to have the std::ifstream reverse the bytes itself, i.e. by reading the bytes in reverse order?
I find it overkill to reverse each integers afterward if there is a way to have them read backward from the start