From: broeker AT acp3bf DOT knirsch DOT de (Hans-Bernhard Broeker) Newsgroups: comp.os.msdos.djgpp Subject: Re: 64 bit integer, putc and double. Date: 9 Sep 1999 17:26:50 +0200 Organization: RWTH Aachen, III. physikalisches Institut B Lines: 41 Message-ID: <7r8jjq$926@acp3bf.knirsch.de> References: <7r8ied$9im$1 AT news7 DOT svr DOT pol DOT co DOT uk> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 936890814 18189 137.226.32.75 (9 Sep 1999 15:26:54 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 9 Sep 1999 15:26:54 GMT X-Newsreader: TIN [version 1.2 PL2] To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com 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 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.