How to write to the Output window in Visual Studio?

前端 未结 7 2036
小鲜肉
小鲜肉 2021-01-30 02:39

Which function should I use to output text to the \"Output\" window in Visual Studio?

I tried printf() but it doesn\'t show up.

7条回答
  •  一向
    一向 (楼主)
    2021-01-30 03:29

    OutputDebugString function will do it.

    example code

        void CClass::Output(const char* szFormat, ...)
    {
        char szBuff[1024];
        va_list arg;
        va_start(arg, szFormat);
        _vsnprintf(szBuff, sizeof(szBuff), szFormat, arg);
        va_end(arg);
    
        OutputDebugString(szBuff);
    }
    

提交回复
热议问题