C - Pointers Vs Multidimensional Arrays

From EdWiki

Revision as of 06:51, 7 March 2012 by Jshankar (Talk | contribs) (1 revision)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Pointers Vs Multidimensional Arrays

int ar[10][20]; // two-dim array
int* ap[10];	// array of pointers to ints
  • ar is a true two-dimensional array.
  • For ap, however, the definition only allocates 10 pointers and doesn’t initialize them.
  • The advantage of the pointer array is that the rows of the array may be of different lengths.