www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/05/12/03:00:59

Date: Sun, 12 May 1996 09:53:33 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
Cc: djgpp AT delorie DOT com
Subject: Re: i/o file handling - intege
In-Reply-To: <Pine.SGI.3.91.960509230139.22134A@tower.york.ac.uk>
Message-Id: <Pine.SUN.3.91.960512094613.25343C-100000@is>
Mime-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019