Mail Archives: djgpp/1996/05/12/03:00:59
On Thu, 9 May 1996, Shawn Hargreaves wrote:
> If you are interested in portability, it is worth considering the
> implications of endianess.
[snip]
> The best way I've found to deal with this is to define two versions of
> getw and putw, one for each endianness. You call whichever one your file
> format is using, making sure always to read 16 and 32 bit variables with
A better way is to convert your int's to the so-called ``network'' format
by calling `htonl' library function (and `ntohl' for the reverse
conversion). These functions are POSIX and ensure the data written to
the file can be read on any other machine that has a POSIX compiler.
- Raw text -