How to write to the Output window in Visual Studio?

前端 未结 7 2093
小鲜肉
小鲜肉 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:42

    Use the OutputDebugString function or the TRACE macro (MFC) which lets you do printf-style formatting:

    int x = 1;
    int y = 16;
    float z = 32.0;
    TRACE( "This is a TRACE statement\n" );    
    TRACE( "The value of x is %d\n", x );
    TRACE( "x = %d and y = %d\n", x, y );
    TRACE( "x = %d and y = %x and z = %f\n", x, y, z );
    

提交回复
热议问题