Home Segments Index Top Previous Next

274: Mainline

To define an array, you need an array definition that tells C the name of the array, the type of objects that the array is to contain, the number of dimensions the array has, and the size of each dimension. The C compiler uses array definitions to calculate how much storage to allocate for the array.

The following array definition, for example, tells the C compiler to allocate memory for a one-dimensional array containing five numbers of type double, each of which represents the price per share of the stock involved in one of five stock trades:

 *-- Specifies that the array contains floating-point objects 
 | 
 |      *-- Specifies that the name of the array is number 
 |      | 
 |      |    *-- Specifies that the array contains five objects 
 |      |    | 
 v      v    v 
double price[5];