Steven
Steven

Reputation:

How do I pipe output when debugging in Visual Studio?

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

Upvotes: 3

Views: 1912

Answers (3)

call me Steve
call me Steve

Reputation: 1727

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

You can redirect stdout/err/in from your program as well. find a sample in c++ hereafter the only advantage over the first simpler solution is to be portable.

#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;
}

Upvotes: 1

Kasper
Kasper

Reputation: 1708

Just checking, you are not looking for outputting within Visual Studio using stuff like

System.Diagnostics.Debug.WriteLine("this goes into the Output window");

right?

Upvotes: 1

Igal Serban
Igal Serban

Reputation: 10684

In project properties:

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

Upvotes: 4

Related Questions