<CAP-ht1CQKVByZt1EXOb3J7TF=McCKi=EtzjEH+CaEsPtvY5=jg@mail.gmail.com>
Heey! Excellent text! But if you permit me to point, there is a easier way to use VLA to multidimensional arrays, like that: void printMatrix(int n) { int (*mat)[n] = malloc(sizeof(*mat)*n); for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { mat[i][j] = i + j; printf("%d ", mat[i][j]); } printf("\n"); } } Att brudel
<20200210171949.unl3nhytqwl2bvu3@nullprogram.com>
<CAP-ht1CQKVByZt1EXOb3J7TF=McCKi=EtzjEH+CaEsPtvY5=jg@mail.gmail.com>
(view parent)
Oh, duh, you're right! It seems so obvious now that you've spelled it out. I've added an update to my article about this. Thanks!