​​out.t...">

How can I output output when debugging in Visual Studio?

For example, if I wanted to do this from the command line, I would use "a.exe> ​​out.txt". Is it possible to do something like this in Visual Studio while debugging (F5)?

+1


source to share


3 answers


In project properties:



  • enter command line arguments "> out.txt"
  • Disable hosting process
+3


source


Just by checking, you are not looking for output in Visual Studio using things like

System.Diagnostics.Debug.WriteLine ("it goes into the output window");



right?

+1


source


You can redirect using the "command argument" in the project properties.

You can also redirect stdout / err / in from your program. find a pattern in C ++ later on, the only advantage over the first simpler solution is portability.

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main ()
{
#ifdef _DEBUG
    ofstream mout("stdout.txt");
    cout.rdbuf(mout.rdbuf());
#endif
    cout<< "hello" ;
    return 0;
}

      

+1


source







All Articles