If you want to declare an array in C, you need to specify the type of elements and the number of elements, as follows:
type arrayName [ arraySize ];
arraySize must be an integer greater than zero Constant, type can be any valid C data type.
(Recommended tutorial: C Language Tutorial)
For example, to declare an array balance of type double containing 10 elements, the declaration statement is as follows:
double balance[10];
Now balance is an available array that can hold 10 numbers of type double.
Specific elements in an array can be accessed by index. All arrays are composed of contiguous memory locations. The lowest address corresponds to the first element, and the highest address corresponds to the last element.
The above is the detailed content of How to define an array in c++. For more information, please follow other related articles on the PHP Chinese website!