Did you create the file on the same computer? Binary files are highly non-portable. This simple test works fine for me:
Code:
itsme@itsme:~/C$ cat dblbin.c
#include <stdio.h>
int main(void)
{
double array[] = { 3.4, 7.2, 95.7, 104.9, 0.13 };
FILE *fp;
int count;
int i;
if(!(fp = fopen("dblbin.test", "wb")))
{
puts("Couldn't open dblbin.test for writing!");
return 1;
}
count = fwrite(array, sizeof(double), 5, fp);
fclose(fp);
printf("Wrote %d items.\n", count);
if(!(fp = fopen("dblbin.test", "rb")))
{
puts("Couldn't open dblbin.test for reading!");
return 1;
}
count = fread(array, sizeof(double), 5, fp);
fclose(fp);
printf("Read %d items.\n", count);
for(i = 0;i < count;++i)
printf("%f ", array[i]);
putchar('\n');
return 0;
}
Code:
itsme@itsme:~/C$ ./dblbin
Wrote 5 items.
Read 5 items.
3.400000 7.200000 95.700000 104.900000 0.130000