和printf 提供的功能类似,但是TRACE输出到system debugger的debug output窗口,典型的system debugger就是VC(还有windbg, dbgviewer等等)
// example for TRACE
int i = 1;
char sz[] = "one";
TRACE( "Integer = %d, String = %s\n", i, sz );
// Output到vc的debug output窗口: 'Integer = 1, String = one'

解决方案 »

  1.   

    类似printf一样的函数,不同的是TRACE将格式字串送往DEBUG的OUTPUT区,在调程序时可以很方便在将一些信息反馈给程序员。以下代码出自MSDN
    // example for TRACE
    int i = 1;
    char sz[] = "one";
    TRACE( "Integer = %d, String = %s\n", i, sz );
    // Output: 'Integer = 1, String = one'// another example for TRACE
    // Note that the TRACE() macro accepts a LPCTSTR for the format string
    // parameter, while the other TRACEn() macros accept a LPCSTR.
    // This means that you should use the _T() macro on formatting strings 
    // you supply if you want to build both _UNICODE and non-_UNICODE from
    // the same source.TRACE(_T("Hockey is best!\n"));// remember to include <stdlib.h> to get rand() and its friendsint nCount = rand();
    TRACE(_T("There are %d fans at this moment.\n"), nCount);
      

  2.   

    TRACE主要用于程序调试,用法相当于printf语句,在VC的Output区输出“ ”中的内容以跟踪程序运行或者查看一些变量的值。