C语言 OutputDebugString与格式化输出函数OutputDebugPrintf案例详解

  #include

  #include

  //#include

  #include

  #define IS_USE_OUTPUT_DEBUG_PRINT 1

  #if IS_USE_OUTPUT_DEBUG_PRINT

  #define OUTPUT_DEBUG_PRINTF(str) OutputDebugPrintf(str)

  void OutputDebugPrintf(const char * strOutputString, ...)

  {

  #define PUT_PUT_DEBUG_BUF_LEN 1024

  char strBuffer[PUT_PUT_DEBUG_BUF_LEN] = { 0 };

  va_list vlArgs;

  va_start(vlArgs, strOutputString);

  _vsnprintf_s (strBuffer, sizeof(strBuffer) - 1, strOutputString, vlArgs); //_vsnprintf_s _vsnprintf

  //vsprintf(strBuffer,strOutputString,vlArgs);

  va_end(vlArgs);

  OutputDebugStringA(strBuffer); //OutputDebugString // OutputDebugStringW

  }

  #else

  #define OUTPUT_DEBUG_PRINTF(str)

  #endif