This is the code snippet.
typedef struct Lib3dsMesh {
//..
float (*vertices)[3];
//..
}
void* lib3ds_util_realloc_array(void *ptr, int old_size, int new_size, int element_size) {
// Do something here.
return ptr;
}
mesh->vertices = lib3ds_util_realloc_array(mesh->vertices, mesh->nvertices, nvertices, 3 * sizeof(float));
When I compile this code in visual c++ it returns error “Cannot convert from void* to float(*)[3]”.
I would like to know how to cast void * to float (*vertices)[3];
verticesis a pointer to a 3-element array offloat. To do a cast from one pointer type to another, you generally usestatic_cast: