Browse - Programming Tips - Why is my memory holding 0xbaadf00d ?

Date: 2017aug29
Product: MSVC
Language: C/C++

Q.  Why is my memory holding 0xbaadf00d ?

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)