Initialising C static arrays

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andrew Davie

I had no idea you could do this... apparently not standard C, but supported by GCC.
If you want to initialise a static array with a non-zero value, you can do this...

static int x[10] = { 5,5,5,5,5,5,5,5,5,5 };

OR... you can do this....

static int x[10] = { [0 ... 9] = 5 };


I was today years old!
It's cool when you get super-big static arrays.