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
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!