What is the meaning of this initialization:
char arr[10] = { 0, };
I'm familiar with char arr[10] = {0};
which sets all the elements to zero, and with char arr[10] = {1,2};
which sets the first two elements to 1 and 2 (ascii) and the rest to 0.
I'm not familiar with the format above.
A quick test showed that it's probably just like char arr[10] = {0};
, but is there other meaning I'm not aware of?
Best Answer
From How to initialize all members of an array to the same value?:
Initialize all members to the same value:
Elements with missing values will be initialized to 0:
So this will initialize all elements to 0:
In C++, an empty initialization list will also initialize every element to 0:
Objects with static storage duration will initialize to 0 if no initializer is specified:
If your compiler is GCC you can use following syntax: