Listing 1: Using pointers to arrays

void ex1()
{
    int i;
    int a[3];
    int (*pa)[3] = &a;

    for (i = 0; i < 3; ++i)
        (*pa)[i] = 1;

    // Save the result of calling f()
    // so the bounds of vla, pvla, and
    // the loop will be consistent even
    // if f() returns a different value
    // each time it is called
    int bounds = f();
    int vla[bounds];
    int (*pvla)[bounds] = &vla;

    for (i = 0; i < bounds; ++i)
        (*pvla)[i] = 1;
}
— End of Listing —