Search code examples
c++visual-studio-2013cout

Visual Studio 2013: Redirecting console output to Visual Studio Output Window


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


Solution

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