#include <stdio.h>
#include <stdlib.h>
int main(void)
{
FILE *fp;
double d = 1.23;
int i = 10;
long l = 13333023L;
if(( fp = fopen("my.txt", "wb+")) == NULL) {
printf("Cannot open file.\n");
exit(1);
}
fwrite(&d, sizeof(double), 1, fp);
fwrite(&i, sizeof(int), 1, fp);
fwrite(&l, sizeof(long), 1, fp);
rewind(fp);
fread(&d, sizeof(double), 1, fp);
fread(&i, sizeof(int), 1, fp);
fread(&l, sizeof(long), 1, fp);
printf("%f %d %ld", d, i, l);
fclose(fp);
return 0;
}
|