Originally Posted by
Malcolm McLean
Windows encourages this approach in its own functions for manipulating .bmp files. However really it is bad way of doing it. C can run on big or litle-endian machines, and the sizes of basic types can vary. You also sometimes get unexpected padding in structures.
It's better to read field by field, with code that will work regardless of the endianness or integer size of the platform. See my website for a source file which helps you do this (the iee754 project).