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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -