c language base ---- Array

Arrays are composed of contiguous memory locations. The lowest address corresponds to the first element, the highest address corresponding to the last element.

Declare an array

type arrayName [ arraySize ];

Called a one-dimensional array. arraySize  must be an integer constant greater than zero, type  can be any valid C data types.

 

Array initialization

In C, you can initialize the array one by one, you can also use an initial statement, as follows:

double balance[5] = {1000.0, 2.0, 3.4, 7.0, 50.0};

The number of values ​​between the braces {} is not larger than the number of elements in an array we specify a statement in square brackets [].

The number of elements in the initialization If you omit the size of the array, the array size was. Therefore, if:

double balance[] = {1000.0, 2.0, 3.4, 7.0, 50.0};

Guess you like

Origin www.cnblogs.com/xuey/p/12205391.html