Mail Archives: djgpp/1999/09/09/18:16:42
Tom Morton (tmorton AT yikesstation DOT freeserve DOT co DOT uk) wrote:
> I have 2 questions:
> 1. Does djgpp support 64-bit integers?
Yes. GCC supports 'long long int' as a way to access 64bit integers,
on 32bit machines.
> 2. I need to store float and double variables in a binary savegame file.
> How is this done using getc/putc.
It is done *not* using getc/putc. There are *much* simpler ways to do
it.
> My plan is to shove the address of
> the float into a long integer pointer and then write the float to the
> file as if it is an 32-bit integer.
[...]
You're thinking about it in an overly complicated way. Just open your
C textbook (or the DJGPP libc manual, 'info libc') and look up
functions 'fwrite' and 'fread'. In a nutshell:
#include <stdio.h>
double myDouble;
int myInt;
FILE *myFile = fopen("filename", "wb");
fwrite (&myDouble, sizeof(double), 1, myFile);
fwrite (&myInt, sizeof(int), 1, myFile);
fclose (myFile);
Caveat: if there is any chance your program will ever be ported/used
on any other type of computer, try *not* to use raw binary file
I/O. That type of file is not portable from one architecture to an
other, and you had better avoid it, thus.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -