Mail Archives: djgpp/1997/10/02/06:47:11
From: | Erik Max Francis <max AT alcyone DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Problems with fread and fwrite - program
|
Date: | Wed, 01 Oct 1997 09:41:36 -0700
|
Organization: | Alcyone Systems
|
Lines: | 28
|
Message-ID: | <34327D40.71978D38@alcyone.com>
|
References: | <60tli0$7d3$2 AT loki DOT cf DOT ac DOT uk>
|
NNTP-Posting-Host: | newton.alcyone.com
|
Mime-Version: | 1.0
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Emyr James wrote:
> Oops!! forgot to include the program.....
Yours was one of the fairly rare cases where one could determine the
likely problem just from the description . . .
> void main(void)
Nitpick: main must return int according to ANSI C 5.1.2.2.1.
> fp=fopen("ran.bin","r");
As I suspected, here's the problem. You're writing binary data to the
file (can't get much more binary than the internal representation of
doubles), but you're opening the file in text mode. Change this line to
fp = fopen("ran.bin", "rb");
and your program should work fine.
--
Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
Alcyone Systems / http://www.alcyone.com/max/
San Jose, California, United States / icbm://+37.20.07/-121.53.38
\
"After each war there is a little / less democracy to save."
/ Brooks Atkinson
- Raw text -