3 ms·
Heap-allocated dynamically-sized NxM matrix in C99: double (*mat)[M] = calloc(N * M, sizeof (double));
by cygx 8y ago
Heap-allocated dynamically-sized NxM matrix in C99:
double (*mat)[M] = calloc(N * M, sizeof (double));
- int_19h 8y agoAh, good point. I always forget that VLA types in C99 are actually types, and so you can use them in these contexts as well. It's a shame they killed VLAs as a mandatory language feature. They didn't make C into Fortran (which I think was the hope, between them, complex numbers, and "restrict"?), but they did make some things a great deal more pleasant to write.