I need to return a structure with a flexible array member from a C function but can\'t figure out why it doesn\'t compile. I know that returning arrays can be achieved by en
I use gcc and I think may be this way is ok:
struct data_array { long length; double* data; }; struct data_array* test (int length) { struct data_array* a =(struct data_array *) malloc (sizeof (data_array)); a->data = malloc (length*sizeof(double)); a->length = length; return a; }