filmov
tv
Designated list Initialization (ISO C99) in array C/C++

Показать описание
This video show the Explicit intialization of array elements .
With designated list initialization (ISO C99), explicit initialization of the array members is
possible. For example,
int array[5] = {[2] = 5, [1] = 2, [4] = 9}; array is {0, 2, 5, 0, 9}
In most cases, the compiler can deduce the length of the array for you, this can be achieved by leaving the
square brackets empty:
int array[] = {1, 2, 3}; /* an array of 3 int's */
int array[] = {[3] = 8, [0] = 9}; /* size is 4 */
With designated list initialization (ISO C99), explicit initialization of the array members is
possible. For example,
int array[5] = {[2] = 5, [1] = 2, [4] = 9}; array is {0, 2, 5, 0, 9}
In most cases, the compiler can deduce the length of the array for you, this can be achieved by leaving the
square brackets empty:
int array[] = {1, 2, 3}; /* an array of 3 int's */
int array[] = {[3] = 8, [0] = 9}; /* size is 4 */