Under VS's external tools settings there is a "Use Output Window" check box that captures the tools command line output and dumps it to a VS tab.
The question is: can I get the same processing for my program when I hit F5?
Edit: FWIW I'm in C# but if that makes a difference to your answer then it's unlikely that your answer is what I'm looking for.
What I want would take the output stream of the program and transfer it to the output tab in VS using the same devices that output redirection ('|' and '>') uses in the cmd prompt.
Maybe this will work for you: set a breakpoint on the close
}
inMain
, and then look at the console window before it closes. You can even copy the text out of it if you need to.On every machine that I use for development, I configure my console window in a certain way, which happens to make this approach work better:
You can use Systems.Diagnostics.Trace class to write your output to the Output window instead of (or in addition to) the console. It take a little configuration, but it works. Is that along the line of what you want?
You can also add your own tab per this article, but I've never tried it.
I'm going to make a few assumptions here. First, I presume that you are talking about printf output from an application (whether it be from a console app or from a windows GUI app). My second assumption is the C language.
To my knowledge, you cannot direct printf output to the output window in dev studio, not directly anyway. [emphasis added by OP]
There might be a way but I'm not aware of it. One thing that you could do though would be to direct printf function calls to your own routine which will
You could do several things to accomplish this goal. First would be to write your own printf function and then call printf and the OuputDebugString()
The code above is mostly untested, but it should get the concepts across.
If you are not doing this in C/C++, then this method won't work for you. :-)
You should be able to capture the output in a text file and use that.
I don't have a VS handy, so this is from memory:
> output.txt
"If things work the way I remember, this will redirect STDOUT to a file, even though you're not actually running under CMD.EXE.
(The debugger has its own implementation of redirection syntax, which is not 100% the same as cmd, but it's pretty good.)
Now, if you open this file in VS, you can still see the output from within VS, although not in exactly the same window you were hoping for.
System.Diagnostics.Debug.Writeline() or Trace.Writeline()
The console can redirect it's output to any textwriter. If you implement a textwriter that writes to Diagnostics.Debug, you are all set.
Here's a textwriter that writes to the debugger.
Since it uses Diagnostics.Debug it will adhere to your compiler settings to wether it should write any output or not. This output can also be seen in Sysinternals DebugView.
Here's how you use it:
If you want to see the output in Sysinternals DebugView when you are compiling in Release mode, you can use a TextWriter that writes to the OutputDebugString API. It could look like this: