MyStruct s1 = { 0 };
Using this king of initialization, you initialize the first element of the structure. If the value does not match the type of the element, the compiler (for example, gcc or g ++) will try to make some implicit translation. All other items will be set to the default value.
MyStruct s3 = { sizeof(MyStruct) };
- this is the same, the first value of the element will be the size of the structure in bytes.
MyStruct s2 = { };
Finally, this initialization is valid only in C ++, the equivalent in C is MyStruct s2; . It initializes all default values.
source share