www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/13/13:45:40

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Binary files and Arrays with DJGPP
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <c1evrssk8gnco7fbj2r0hkv4qgh5a4iui7@4ax.com>
References: <8pod85$l92$1 AT lure DOT pipex DOT net>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 27
X-Trace: /K49oEeRy2CM1NbsaFmc3AjFj6pZpMYLuUmKBXA9Sm6d46nJfoCZuNBDMahxHstrhJziSo5rQxmb!BGoZqa9MuiLfDalSIED7gkix7EdfYCTvO3Jun7i9wJQhlAkUD05t1QfQe4bZjwgfPCafppGdZv/R!Kw==
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Wed, 13 Sep 2000 17:27:41 GMT
Distribution: world
Date: Wed, 13 Sep 2000 17:27:41 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Wed, 13 Sep 2000 18:18:48 +0100, "mapt15" <mapt15 AT dial DOT pipex DOT com>
wrote:

>I'd like to know how to use binary files to store multidimensional
>arrays, and also to load into multidimensional arrays.
>
>What's the best way to do this?

The most portable way is storing as text, but this is nearly out of
the question efficiency-wise for large multidimensional arrays.

The second most portable way is to serialize your binary arrays.
This means outputting them 8 bits at a time, using shift operators to
break the data items up into bytes.  To read them back, reassemble
the bytes back into data items.

The least portable way (fwrite()/fread()) is deprecated because it
causes problems with alignment and endianness when files are moved
between architectures.

-- 
MS (n)  1. A debilitating and surprisingly widespread affliction
  that renders the sufferer barely able to perform the simplest
  task.  2. A disease, multiple sclerosis (see).

This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses.  http://www.mcafee.com/

- Raw text -


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