Prasad said:
To add -
If you wish to only init few items then you may use :
int x[5] = {9, 3};
In the above example, only the first two elements are set to the values
mentioned, most compilers do initialise the rest of the elements to
zero.
This is guaranteed.
Though, not sure what the ANSI "C" standards book says about the init
of the remaining elements.
In the case of a partially-initialised aggregate or union object,
"all subobjects that are not initialized explicitly shall be
initialized implicitly the same as objects that have static
storage duration." - 6.7.8(19).
"If an object that has static storage duration is not initialized
explicitly, then:
— if it has pointer type, it is initialized to a null pointer;
— if it has arithmetic type, it is initialized to (positive or
unsigned) zero;
— if it is an aggregate, every member is initialized (recursively)
according to these rules;
— if it is a union, the first named member is initialized (recursively)
according to these rules." - 6.7.8(10).