Missing. The end result is that both initialize the members of the structure to 0 .
C99 Standard 6.7.8.21
If the list enclosed in brackets contains fewer initializers than the element or elements of the collection or fewer characters in the string literal used to initialize an array with a known size than in the array, the rest of the aggregate must be initialized implicitly in the same way as objects, having a static storage duration.
Your structure A is aggregating, and the above rule applies to it. Thus, all elements of the structure are initialized with the same accuracy as for the static storage duration. This is 0 .
C99 Standard 7.21.6.1 memset function:
void *memset(void *s, int c, size_t n);
The memset function copies the value of c (converted to unsigned char) to each of the first n characters of the object pointed to by s .
In simple words, all members, including the alignment / padding bits in the object of your structure A , are set to 0 .
Note that the difference between the two constructs in C is that memset also sets the alignment / padding to 0 , while aggregate initialization only guarantees that your structure members are set to 0 .
In any case, you do not have access to alignment / padding bytes through the conventions language constructs and, therefore, both effects will get the same effect.
Alok save
source share