Is it possible that in different program executions the code above is not going to work?
Yes, it’s about as possible as 1+1==2
.
Is this correct?
Absolutely.
How can I solve the problem?
Write and read the array rather than its address:
vl_size size = vl_get_type_size(dataType);
const void *means = vl_gmm_get_means(gmm)
out.write(static_cast<const char*>(means), numComponents * dimension * size);
/// ...
vl_size size = vl_get_type_size(dataType);
void *means = vl_calloc (numComponents * dimension, size) ;
in.read(static_cast<char*>(means), numComponents * dimension * size);
6
solved Writing void pointer to binary file