~skeeto/public-inbox

1

https://nullprogram.com/blog/2019/10/27/

bru del
Details
Message ID
<CAP-ht1CQKVByZt1EXOb3J7TF=McCKi=EtzjEH+CaEsPtvY5=jg@mail.gmail.com>
DKIM signature
pass
Download raw message
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
Details
Message ID
<20200210171949.unl3nhytqwl2bvu3@nullprogram.com>
In-Reply-To
<CAP-ht1CQKVByZt1EXOb3J7TF=McCKi=EtzjEH+CaEsPtvY5=jg@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
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!