Home Segments Index Top Previous Next

291: Mainline

To define a one-dimensional trade array, you must define the trade structure first; then, you can write an array definition, as you would to define any array.

The following statement, for example, is an array definition that tells C to allocate memory for a one-dimensional array, named trades, containing three trade objects:

      *-- Specifies that the array contains trade objects 
      |       *-- Specifies that the name of the array is trades 
      |       |     *-- Specifies that the array contains three objects 
      v       |     | 
------------  v     v 
struct trade trades[3]; 

Thus, an array definition for structure objects looks like an ordinary array definition, except that the symbol struct, with a structure name, such as trade, appears instead of the name of a built-in type, such as int.