cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/29/11:42:46

Date: Thu, 29 Jul 1999 11:27:19 +0200
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Message-Id: <199907290927.LAA05722@acp3bf.physik.rwth-aachen.de>
To: djgpp AT delorie DOT com
Subject: Re: Problems with file I/O and the value 13 (EOF?)
Newsgroups: comp.os.msdos.djgpp
Organization: RWTH Aachen, III. physikalisches Institut B
X-Newsreader: TIN [version 1.2 PL2]
Reply-To: djgpp AT delorie DOT com

In article <19990728 DOT 061228 DOT -4108575 DOT 0 DOT nine1one AT juno DOT com> you wrote:

> Whenever I write the value 13 to a file and read it back I get a large
> number, as if it shifted bytes and is reading a value in the upper byte
> of the short integer. 

> /* create the file of 15 records */
> fptr=fopen("junk","w");
                     ^^^^ make that "wb" and watch the difference
> fptr=fopen("junk","r");
                    ^^^^^ "rb", here.

You're being hit by the difference betweeen what the C standard and
DOS understand as being a 'text file'. Yours isn't really a text file,
at all, so you must *tell* the compiler about that fact.

--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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