#include <stdio.h> #include <wtypes.h> #include <stdarg.h> #include <tchar.h> void LogTrace(LPCTSTR pszFormat, ...) { va_list pArgs; char szMessageBuffer[16380]={0}; va_start( pArgs, pszFormat ); _vsntprintf( szMessageBuffer, 16380, pszFormat, pArgs ); va_end( pArgs ); OutputDebugString(szMessageBuffer); } 另附窗口弹出函数 void printDebugMsg(LPCTSTR pszFormat, ...) { va_list pArgs; char szMessageBuffer[512] ; va_start( pArgs, pszFormat ); sprintf_s( szMessageBuffer, pszFormat, pArgs ); MessageBox(NULL,szMessageBuffer,"",NULL); }