For 0x1234:
In memory, the least significant byte is 34, and the most significant byte is 12.
When written to the file in binary format, the bytes are written in little-endian order.
Therefore, the hexdump shows 34 12 00 00, with the least significant byte 34 appearing first.
For 0x12345678:
In memory, the least significant byte is 78, and the most significant byte is 12.
When written to the file in binary format, the bytes are written in little-endian order.
Therefore, the hexdump shows 78 56 34 12, with the least significant byte 78 appearing first.
--
To save int only can save to text, binary
This post has been edited by cytyler: May 24 2023, 08:18 AM
C How does C/C++ store integer in binary file?, Endianness in x86
May 24 2023, 08:16 AM
Quote
0.0163sec
0.25
6 queries
GZIP Disabled