const int status[STATUS_SIZE] = { [0] = -1, [1] = 0, [2] = 1, };
and
const char *messages[MESSAGE_SIZE] = { [0] = "OK", [1] = "NG", };
Can you explain?
C99 introduces the assigned initializers , with which you can initialize the array in any order using the index.
6.27 Assigned InitializersThe C90 standard requires that initializer elements be displayed in a fixed order, just like the order of elements in an initialized array or structure.In ISO C99, you can specify elements in any order by specifying the array indexes or the names of the structure fields to which they apply, and GNU C allows this as an extension in C90 mode. This extension is not implemented in GNU C ++., [index] = . ,int a[6] = { [4] = 29, [2] = 15 }; int a[6] = { 0, 0, 15, 0, 29, 0 };
6.27 Assigned Initializers
The C90 standard requires that initializer elements be displayed in a fixed order, just like the order of elements in an initialized array or structure.
In ISO C99, you can specify elements in any order by specifying the array indexes or the names of the structure fields to which they apply, and GNU C allows this as an extension in C90 mode. This extension is not implemented in GNU C ++.
, [index] = . ,
[index] =
int a[6] = { [4] = 29, [2] = 15 };
int a[6] = { 0, 0, 15, 0, 29, 0 };
Source: https://habr.com/ru/post/1692395/More articles:Trying to use two separate instances of getline () to populate two separate vectors - c ++Is it possible to return the first non-empty value for different types of Java using options? - javaIs an atomic quantitative group the same as a quantitative atomic group? - regexJavascript isNaN and null - javascriptF # Fake tries to create a Xamarin.iOS binding with the error "btouch-native.exe is not" - xamarinOffer a top-level service or several service workers in the same domain? - service-workerSplit string with two special characters - javaPython: convert first search depth to first search width for all list combinations - pythonMigrating from Struts 1.2.8 to struts2.5.14.1 - springSet element synchronization in java - javaAll Articles