1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
unsigned int * vec;
// ... do something to vec
double * a = (double *) malloc(4*sizeof(double));
a = (double[3]){ (double[3]){0.0,10.0,20.0}[vec[0]],
(double[3]){1.0,2.0,3.0}[vec[1]],
(double[6]){-2.0,-1.0,0.0,1.0,2.0,3.0}[vec[2]]
}; // NO C COMPILER ERROR
double b[3];
b = (double[3]){ (double[3]){0.0,10.0,20.0}[vec[0]],
(double[3]){1.0,2.0,3.0}[vec[1]],
(double[6]){-2.0,-1.0,0.0,1.0,2.0,3.0}[vec[2]]
}; // C COMPILER GIVES ERROR
| |