struct MyStruct { int a; float b; char c; MyStruct() { // default constructor ZeroMemory((LPBYTE)this, sizeof(*this)); } };This works for *some* classes too but be very careful with classes. If you have virtual functions, it will klobber your vtable! So only use on the most simple classes.
Programming Tips - It's such a chore setting each struct member to zero.
Date: 2004Aug22
Updated: 2005Jun1
OS: Windows
Language: C
Keywords: clear, init
Q. It's such a chore setting each struct member to zero.
Is there a faster/less tedious way?
A. Use ZeroMemory() like this: