Is there any difference between this:
struct something s = {};
And this?
struct something s = {0};
From all I know, both initialise every member to zero.
struct something s = {};
isn't valid C (unless they added it in C11), but is valid C++. GCC seems to allow it in C programs as an extension (though I don't see it mentioned in the docs on http://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html, but I might just be missing it).
In C++ it will result in 'value-initialization', which basically means that the default constructor is called for each member (zero-initialization for non-class members).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With