Mail Archives: djgpp/1998/04/03/07:36:07
From: | fist1000 AT aol DOT com (Fist1000)
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Converting pascal 6-byte reals to C 8-byte doubles
|
Date: | 3 Apr 1998 12:18:14 GMT
|
Lines: | 41
|
Message-ID: | <1998040312181401.HAA20698@ladder03.news.aol.com>
|
NNTP-Posting-Host: | ladder03.news.aol.com
|
Organization: | AOL http://www.aol.com
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Not sure where I should post this, but here goes:
A friend of mine has written a program in TP7 and in it he uses a bunch of
reals and writes them to disk. I'm helping him port his code to C (Watcom C),
but I'm at a loss as to how I read in this data from a C program. For example,
I wrote this test in Pascal:
(**********************)
program WriteReal;
var
r : real;
f : file of real;
begin
r := 3.14159;
assign(f,'real.log');
rewrite(f);
write(f, r);
close(f);
end.
(**********************)
Then I wrote a simple C prog to read the file written:
//////////////////////////////
void main(void)
{
double dbl = 0.0;
FILE * f = fopen("real.log", "rb");
fread(&dbl, 6, 1, f);
fclose(f);
printf("%f", dbl);
}
//////////////////////////////
Yet when I run the C prog, I get an output of 0.000000. Does anyone know how to
do this?
Thanks,
Aen (fist1000 AT aol DOT com)
- Raw text -