jeudi 30 mai 2019

Initialize array whose size is a compile-time constant to single value

I have a c-style array whose size is defined by a #define and can change based on compiling options, e.g.

#if LINUX
# define SIZE 4
#else
# define SIZE 5
#endif
static int myArr[SIZE] = { /* ??? */ };

How can I initialize the whole array to a non-zero value, for example all 42?

Aucun commentaire:

Enregistrer un commentaire