Programming Tips - Windows: Why is my memory holding 0xbaadf00d (bad food)?

Date: 2017aug29 Product: MSVC Language: C/C++ Q. Windows: Why is my memory holding 0xbaadf00d (bad food)? A. In debug mode Microsoft Visual C++ fills heap memory with this. eg:
class MyClass { DWORD dwHello; } main() { MyClass myclass = new MyClass(); // Allocate in the heap printf("%x\n", myclass.dwHello); }
The fix is to initialize class members in the constructors. More info http://www.davekb.com/search.php?target=0xcccccccc https://en.wikipedia.org/wiki/Magic_number_(programming)