Debug_Trace.h
#if !defined(DEBUG_TRACE_INCLUDE_) #define DEBUG_TRACE_INCLUDE_ #include <stdio.h> #include <wTypes.h> #include <tchar.h> void Debug_TraceA(char* fmt, ...); #endif
Debug_Trace.cpp
#include "Debug_Trace.h" void Debug_TraceA(char* fmt, ...) { char buf[32*1024] = {0}; va_list args; va_start( args, fmt ); vsprintf( buf, fmt, args ); va_end( args ); OutputDebugStringA( buf ); }
Debug_TraceA("FILE: %s, LINE: %d… ", __FILE__, __LINE__);
网上看到的,试了一把只能在debugview里面看,不能在窗口里面看
void OutputDebugPrintf(char * ptzFormat, ...) { va_list vlArgs; char tzText[1024]; va_start(vlArgs, ptzFormat); vsprintf(tzText, ptzFormat, vlArgs); OutputDebugStringA(tzText); va_end(vlArgs); }