c - Read double from void * buffer -
please excuse lack of understanding, i'm beginner c. so, have void *
buffer calloc
this:
void * databuffer = calloc(samples, sizeof(double));
and later read this:
double mydoubledb = databuffer[sampleindex];
but error because of different types (void , double).
how can achieve this? arch arm , i'm using gcc compile
update: databuffer
out of reach (other library) , comes void *
if can make pointer double
in first place, better.
double * databuffer = calloc(samples, sizeof *databuffer); double mydoubledb = databuffer[sampleindex];
otherwise, unsafely explicitly convert void*
double*
cast:
void * databuffer = calloc(samples, sizeof (double)); double mydoubledb = ((double*)databuffer)[sampleindex];
Comments
Post a Comment