调试的三个工具:TRACE,afxDump,MessageBox。
1、afxDump<<"/n 变量i 的值为:"<<i;
VC中的dump是一个对象内容的标准方法,它的输出流是流向调试窗口,所以必须保证程序是调试版。
程序也可以建造调试模式:
#ifdef _DEBUG
afxDump<<"/n 变量i 的值为:"<<i;
#endif
2、TRACE is limited to sending a total of 512 characters at a time. If you call TRACE with formatting commands, the total string length after the formatting commands have been expanded cannot be more than 512 characters, including the terminating NULL. Exceeding this limit causes an ASSERT.
// example for TRACE
TRACE0 is similar to TRACE, and is one variant of a group of trace macros that you can use for debug output. The group includes:
TRACE0 - Takes a format string (Only) and can be used for simple text messages which are dumped to afxDump
TRACE1 - Takes a format string plus one argument (one variable which is dumped to afxDump)
TRACE2 - Takes a format string plus two arguments (two variables which are dumped to afxDump)
TRACE3 - Takes a format string plus three arguments (three variables which are dumped to afxDump)
TRACE0 does nothing if you have compiled a release version of your application. As with TRACE, it only
dumps data to afxDump if you have compiled a debug version of your application.