delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/15/23:27:33

From: Weiqi Gao <weiqigao AT a DOT crl DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: big-endian and little endian binaries
Date: Sat, 15 Jan 2000 22:07:32 -0600
Organization: CRL Network Services
Lines: 17
Message-ID: <38814404.1FCB80A@a.crl.com>
References: <85reog$bqi$1 AT plato DOT harvard DOT edu>
NNTP-Posting-Host: a116023.stl1.as.crl.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.12-20 i586)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Greg Wellenius wrote:
> 
> Hello,
> 
> Any ideas on how, in C++,  I might be able to write big-endian numbers
> (2-byte ints in this case) to a binary file when I'm on a machine that uses
> little-endian format?
> 
> Might there be a special way to open the output file so that numbers are
> written as big-endian?

None that I known of.  You have to switch the bytes around by hand. 
There are fancier ways of doing it, I'm sure.

-- 
Weiqi Gao
weiqigao AT a DOT crl DOT com

- Raw text -


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