Example 1
A small implementation of the Debug functions
#include <iostream.h> #include <crtdbg.h> #include <string.h> int main() { char *ptr1; _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT); _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); ptr1 = new char[100]; strcpy(ptr1,"This memory leak was created by Sumit"); cout << ptr1 << endl; /* lot of code here */ _CrtDumpMemoryLeaks(); return 0; }