int a[5][3]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
This is a true two dimensional array: 15 int
sized locations have been set aside and the conventional rectangular subscript is used to find the element a[row][col]
int *b[5];
This is an array of pointers which allocate 5 pointers and is not initialized but a[3][2]
and b[3][2]
are both syntactically legal references to a single int.
Assuming that each element of b
does
point to a three-element array, then there will be 15 ints
set aside, plus five cells for the
pointers.
The important advantage of the pointer array is that the rows of the array may be of
different lengths. That is, each element of b
need not point to a three-element vector, some
may point to two elements, some to nine, and some to none at all.