1、强制设置断点:
__asm { int 3 }
2、Release版输出可以用Dbgview查看调试信息:
#include
"
stdafx.h
"
#include
<
windows.h
>
#include
<
stdio.h
>
void
WINAPI DebugString(LPCSTR format, ...)
...
{va_list arglist;char buffer[1024];va_start (arglist,format);vsprintf(buffer, format, arglist);va_end (arglist);strcat(buffer, " ");OutputDebugString (buffer);}
int
main(
int
argc,
char
*
argv[])
...
{ int i;printf("Hello World! "); for (i=0; i<3; i++) DebugString("Hello: %d", i);return 0;}
3、内存泄漏检测//要包含的头文件#ifdef _DEBUG#define _CRTDBG_MAP_ALLOC#include <stdlib.h>#include <crtdbg.h>#endif
//设置报告模式、在发生内存的地方设置断点#ifdef _DEBUG _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_DEBUG); _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); _CrtSetBreakAlloc(141);#endif