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

a 夏天 提交于 2020-04-30 04:57:25

问题


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:


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



来源:https://stackoverflow.com/questions/29305440/visual-studio-2013-redirecting-console-output-to-visual-studio-output-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!