Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Initialization representation method of C language array
Initialization representation method of C language array
Not inta[]? But for example, int a[ 10]. There must be a constant in parentheses.

We can define it like this.

# Define N 5

int,a[N]

This indicates that the array is named a; An array has five elements; They are a[0] to a [4] respectively;

For arrays; An array is a collection of variables, so it also has the same data type and storage type as variables. The type of an array is the type of all its variables. When defining an array, you should determine the type of the array before the array name. Such as IntA [10] above; It means that all elements in the array are integers.

For example, all floating-point types can be defined as float a[ 10]. Examples are as follows:

The extended data array name is a C language identifier named by users, and should follow the rules of identifier naming. The array name represents the first address of the array storage area. The first address of the array is also the address of the first element. Array name is an address constant and cannot be assigned.

The array name is followed by a constant expression enclosed in square brackets, and no other brackets can be used.