FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
C++
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
January 01, 2002

The New C:

(Page 3 of 7)
January 2002/The New C/Listing 3

Listing 3: Using pointers to arrays to process two-dimensional arrays

void ex3()
{
    int i, j;
    int a[3][3];
    int (*pa)[3] = a;

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

    // Save the result of calling f()
    // so the bounds of vla, pvla, and
    // the loop will be consistent
    int bounds = f();
    int vla[3][bounds];
    int (*pvla)[bounds] = vla;

    for (i = 0; i < 3; ++i)
      for (j = 0; j < bounds; ++j)
        pvla[i][j] = 1;
}
— End of Listing —
Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 Next Page
RELATED ARTICLES
No Related Articles
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK