Organize several variables with the same data type in an ordered form,
to facilitate program processing. The collection of these data elements is an array. According to the array
< p>Elements have different types and can be divided into various categories: numerical arrays, character arrays, pointer arraysstructural arrays, etc.
The general form of array description is:
Type specifier array name [constant expression],...;
Among them type specifier Can be any basic data type or constructed data type
The array name is the defined array identifier. A constant expression represents the number of data elements, that is, the length of the array.
Note on the description of the array type:
1) The type of the array is actually the value type of the array elements.
2) The writing of array names should comply with the writing specifications of identifiers.
3) The array name cannot be the same as other variable names.
4) A constant expression represents the number of array elements, but its subscript starts from 0.
5) Variables cannot be used in square brackets to represent the number of elements. But you can use symbols
constants or constant expressions.
6) Allows multiple arrays and multiple variables to be specified in the same type specification.
The representation method of array elements
It is generally simple to refer to the array name [subscript], define it first and then use it. If
is a decimal, directly Automatic rounding.
Array assignment is divided into: initialization assignment and dynamic assignment
The general form of initialization assignment is:
static type specifier array name [constant expression] = { Value, value...};
static represents a static storage type. The C language stipulates that only static storage arrays and external arrays
can be initialized and assigned.
C language has several provisions for initialization assignment of arrays:
1) You can assign values ??to only some elements.
2) Values ??can only be assigned to elements one by one, not to the entire array.
3) If you do not assign an initial value to an initializable array, you do not need to give the number of elements in the array
in the array description.