Memory has been allocated when the array is defined. Because the space length of the defined array X is 5, the number of bytes occupied by the array X in the memory is 4*5, which is 20 bytes.
In addition, the array initialization int x[5]={0, 2, 4} is the first three elements of the exponential group, that is, x [0], x [1] and x [2] are assigned to 0, 2, 4 in turn, and the last two elements are assigned to 0, which is not without allocating space to them.
Extended data
Array initialization in C language is divided into the following situations:
int array[ 10] = {0, 1,2,3,4,5,6,7,8,9 }; //Initialize the values of the array members when defining the array.
int array[ 10] = {3,7,9 }; //Assign values to the first three digits of the array and set the remaining elements to 0.
int array[ 10]= { 0 }; //Assign all numbers to 0.
int array[] = { 1,2,3,4,5 }; //The length of the array is determined by the defined array elements.
Int array [10]; //If only one array is defined, you can only assign values to elements one by one, but not to the whole array.
Baidu Encyclopedia-Array