I came across an unfamiliar array initialization syntax in the code of xv6. Original code is in syscall.s
static int (*syscalls[])(void) = {
[SYS_fork] sys_fork,
[SYS_exit] sys_exit,
[SYS_wait] sys_wait,
// ...
[SYS_halt] sys_halt,
};
I ran my sample code to confirm this
const char* mystrings[] = {
[2] "this",
[1] "is",
[0] "cool",
};
int main (int argc, char const* argv[])
{
printf("%s %s %s\n",mystrings[0],mystrings[1],mystrings[2]);
return 0;
}
Output was
cool is this
What is this kind of array initialization in C code? Where can i ( find documentation for this? ( I compiled with gcc 4.6.3 )