Mail Archives: djgpp/1996/05/07/13:30:50
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<stdio.h>
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 *
*****************************************************************
- Raw text -