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

Ueli Hofstetter
  • 2,409
  • 4
  • 29
  • 52
  • See this answer maybe? http://stackoverflow.com/questions/2542599/having-the-output-of-a-console-application-in-visual-studio-instead-of-the-conso – Mark Mar 27 '15 at 17:36

1 Answers1

3

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

Andrew Komiagin
  • 6,446
  • 1
  • 13
  • 23
  • 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. – Ueli Hofstetter Mar 27 '15 at 16:52
  • 2
    There is also macro called TRACE() that is widely used. It does call OutputDebugString(str); as well. It is defined in DEBUG build only. – Andrew Komiagin Mar 27 '15 at 16:59
  • I see. But there is definitely no way to somehow configure Visual Studio to do this without any code? Thx for the support. – Ueli Hofstetter Mar 27 '15 at 17:06