O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using Multidimensional Arrays

The power of an array can be greatly increased by creating multidimensional arrays: an array whose element values are also arrays. This concept is tough to visualize (it's roughly equivalent to a stack of two-column tables) but not that hard to use.

All of the same rules for arrays apply to multidimensional arrays. Once again you'll use the square brackets to indicate the number of elements. This time you'll do so twice:

float grades[3][20];

The first number indicates the number of subarrays (or tables, in layman's terms) the main array contains. The second number specifies the number of rows each subarray (table) contains.

Populating multidimensional arrays is also tricky. You first refer to the subarray index ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required