www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/12/01/03:44:19

Date: Tue, 1 Dec 1998 10:44:23 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: dalitz <dalitz AT ulm DOT netsurf DOT de>
cc: djgpp AT delorie DOT com
Subject: Re: Strange behavior of fread
In-Reply-To: <36630cd2.17414449@news.extension.net>
Message-ID: <Pine.SUN.3.91.981201104403.16940N-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com

On Mon, 30 Nov 1998, dalitz wrote:

> It seems to me that the order of two subsequent bytes
> is swapped in the buffer when the fread function reads items of 
> two bytes (short int). I really don't understand what's going
> on.

As others have explained, this is due to the differences in byte order
between HP and Intel CPUs.

You can use library functions `ntohs' and `ntohl' to convert the byte
order of, respectively, 16-bit shorts and 32-bit ints.

- Raw text -


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