Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Assignment of c language array
Assignment of c language array
In addition to assigning values to array elements one by one with assignment statements, initialization assignment and dynamic assignment can also be used.

C language has the following provisions for the initialization assignment of arrays:

1) can only assign initial values to some elements.

When the number of values in {} is less than the number of elements, only the previous elements are assigned.

For example:

int a[ 10]={0, 1,2,3,4 };

It means that only five elements A [0] ~ A [4] are assigned, and the last five elements are automatically assigned to 0.

2) You can only assign values to elements one by one, but not to the whole array.

For example, assigning 1 to all ten elements can only be written as:

int a[ 10]={ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };

It cannot be written as:

int a[ 10]= 1;

The same is true for multidimensional arrays.

In addition to initializing assignment, the method of assigning values to arrays can only assign values to array elements one by one with assignment statements.