#include <stdio.h>
#include <stdlib.h>
int main(void)
{
#define SIZE 5
double A[SIZE] = {1.0, 2.0, 3.0, 4.0, 5.0};
FILE * fp = fopen("test.bin", "wb");
fwrite(A, sizeof(double), SIZE, fp);
fclose (fp);
double B[SIZE];
fp = fopen("test.bin", "rb");
if (fseek(fp, sizeof(double) * 2L, SEEK_SET) != 0)
{
fprintf(stderr, "fseek() failed in file %s at line # %d\n", __FILE__, __LINE__ - 2);
fclose(fp);
return EXIT_FAILURE;
}
int ret_code = fread(B, sizeof(double), 1, fp);
printf("ret_code == %d\n", ret_code);
printf("B[0] == %.1f\n", B[0]);
fclose(fp);
return EXIT_SUCCESS;
}