1

I am used to Eclipse CDT where the output of a program (using cout) is written to the "Console" window inside Eclipse. enter image description here

Now I switched to Visual Studio 2013. When creating a simple C++ "Console Application" like

 #include "stdafx.h" #include <iostream> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { cout << "hello world" << endl; cin.get(); return 0; } 

the application is "run in the Dos console", i.e. when I press "Run" Visual Studio opens a small Dos window and runs the program from there. As a result, the system input and output has to be done over the Dos window as well.

My question is the following: Is it somehow possible to redirect the input and output to the Visual Studio Output window (or any other perspective/view inside Visual Studio)? I am just getting annoyed by the fact there is no integrated console...enter image description here

So basically what I want to achieve is to see the "hello world" output in the "Output" Window of Visual Studio. Is this somehow possible?

Thanks

1

1 Answer 1

3

The most common way of doing that is to use OutputDebugString(str);

Sign up to request clarification or add additional context in comments.

3 Comments

Jop I saw this approach as well. But I am rather looking for a way to redirect the output than to use another method call. I will accept your answer if it turns out that there is no other way to achieve this. Upvoted to give you credit.
There is also macro called TRACE() that is widely used. It does call OutputDebugString(str); as well. It is defined in DEBUG build only.
I see. But there is definitely no way to somehow configure Visual Studio to do this without any code? Thx for the support.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.