Which function should I use to output text to the \"Output\" window in Visual Studio?
I tried printf()
but it doesn\'t show up.
Use OutputDebugString instead of afxDump.
Example:
#define _TRACE_MAXLEN 500
#if _MSC_VER >= 1900
#define _PRINT_DEBUG_STRING(text) OutputDebugString(text)
#else // _MSC_VER >= 1900
#define _PRINT_DEBUG_STRING(text) afxDump << text
#endif // _MSC_VER >= 1900
void MyTrace(LPCTSTR sFormat, ...)
{
TCHAR text[_TRACE_MAXLEN + 1];
memset(text, 0, _TRACE_MAXLEN + 1);
va_list args;
va_start(args, sFormat);
int n = _vsntprintf(text, _TRACE_MAXLEN, sFormat, args);
va_end(args);
_PRINT_DEBUG_STRING(text);
if(n <= 0)
_PRINT_DEBUG_STRING(_T("[...]"));
}