TRACE
TRACE( exp )ParametersexpSpecifies a variable number of arguments that are used in exactly the same way that a variable number of arguments are used in the run-time function printf.ResProvides similar functionality to the printf function by sending a formatted string to a dump device such as a file or debug monitor. Like printf for C programs under MS-DOS, the TRACE macro is a convenient way to track the value of variables as your program executes. In the Debug environment, the TRACE macro output goes to afxDump. In the Release environment, it does nothing.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.Note   This macro is available only in the debug version of MFC.

解决方案 »

  1.   

    拜托,老大,我也看过msdn,感觉不够直观,或者说直白。
      

  2.   

    1.TRACE("aaaaa");
    2.TRACE(str);
      str 为CString 或 char[],char*
    我只用过这两种方法
      

  3.   

    跟MessageBox("helo")相似!不同的是它能自己诊断某些情况等于
    if(...)MessageBox("hello")比如说在Create中,Trace0("fail to Create...");程序会在创建失败时弹出MessageBox();
      

  4.   

    就是在调试时可以在不中断程序的运行,但是可以让自己看到中间的运行结果,不是调试状态下是没用的,用法与sprintf相同.