Xref: news2.mv.net comp.os.msdos.djgpp:3530 From: Robert Hoehne Newsgroups: comp.os.msdos.djgpp Subject: Re: i/o file handling - integers Date: Tue, 07 May 1996 15:51:44 +0200 Organization: TU Chemnitz-Zwickau Lines: 25 Message-ID: <318F5570.3534@Mathematik.tu-chemnitz.de> References: <318E71BD DOT 904 AT algonet DOT se> NNTP-Posting-Host: tantalus-e.hrz.tu-chemnitz.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Rikard Thunberg wrote: > > What is the appropriate way to read/write integers from/to a file with the same size as it is stored in > memory, i.e. a long integer (32bit) would occupy 4 bytes in the file. I have reached a solution but it seems > #include void main() { FILE *fileh; unsigned long my_long=0x41424344; fileh = fopen("test.dat","wb"); fwrite(&my_long,sizeof(my_long),1,fileh); fclose(fileh); } Robert -- ***************************************************************** * Robert Hoehne, Fakultaet fuer Mathematik, TU-Chemnitz-Zwickau * * Post: Am Berg 3, D-09573 Dittmannsdorf * * e-Mail: Robert DOT Hoehne AT Mathematik DOT TU-Chemnitz DOT DE * * WWW: http://www.tu-chemnitz.de/~rho * *****************************************************************