How can I see cout output in a non-console application?

后端 未结 8 2156
醉话见心
醉话见心 2021-02-06 22:10

It seems rather tedious to output to debug window. Where can I find cout output if I am writing a non-console information ?

Like:

double          


        
相关标签:
8条回答
  • 2021-02-06 22:43

    Instead of using cout, create a log file and write anything you want into it.

    Edit: Use this simple code for writing to a log file.

    ofstream log;
    log.open ("log.txt");
    log << "Writing this to a file.\n";
    log.close();
    
    0 讨论(0)
  • 2021-02-06 22:46

    Yes, indeed, it's annoying.

    Here's how I do it :

    #define DBOUT( s )            \
    {                             \
    std::wostringstream os_;    \
       os_ << s;                   \
       OutputDebugStringW( os_.str().c_str() );  \
    }
    // example :    DBOUT("some text " << some_variable << "   some more text" << some_other_varaible << "\n");
    
    0 讨论(0)
提交回复
热议问题