This assumes that the buffer is not what you want to store the data in. All this does is change the way we look at the memory from unsigned chars to doubles.
Code:
extern unsigned char* buffer;
/*allocates new memory, which needs to be freed when finished with*/
double* create_double_array(unsigned char const * const buf, size_t const buf_size)
{
double* f = malloc(buf_size);
if(!f)return f;
memcpy(f, buf, buf_size);
return f;
}
/*read the size of the array from the buffer*/
int array_size = *((int*)buffer);
double* double_array = create_double_array(buffer+sizeof(int),array_size);
if(!double_array) printf("error could not create array");
Note: this assumes the binary file was created on a machine with the same endianness and assumes the data is correct.