In Win32 programming a handful of POD structs is used. Those structs often need to be zeroed out before usage.
This can be done by calling memset()
/ZeroMemory()
STRUCT theStruct;
ZeroMemory( &theStruct, sizeof( theStruct ) );
or by value initialization:
STRUCT theStruct = {};
Although the two variants above are not equivalent in general:
in case of POD structs used in Win32 they look equivalent.
Are there any cases when memset()
/ZeroMemory()
should be used instead of value initialization with Win32 POD structs?
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