Visual Studio 2013:将控制台输出重定向到Visual Studio输出窗口 [英] Visual Studio 2013: Redirecting console output to Visual Studio Output Window

查看:335
本文介绍了Visual Studio 2013:将控制台输出重定向到Visual Studio输出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我习惯了Eclipse CDT,其中程序的输出(使用cout)被写入Eclipse内部的控制台窗口。

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

现在我切换到Visual Studio2013。在创建简单的C ++控制台应用程序时,例如

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; 
    }

应用程序在Dos控制台中运行,即当我按运行 Visual Studio将打开一个小的Dos窗口,然后从那里运行程序。结果,系统的输入和输出也必须在Dos窗口中完成。

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.

我的问题是:是否可以通过某种方式重定向输入和输出到Visual Studio的输出窗口(或Visual Studio中的任何其他透视图/视图)?我对没有集成控制台的事实感到恼火。

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...

所以基本上我想要实现的是在Visual Studio的输出窗口中看到 hello world输出。

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?

谢谢

推荐答案

最常见的方法这样做是使用 OutputDebugString(str);

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

这篇关于Visual Studio 2013:将控制台输出重定向到Visual Studio输出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆