问题
I am used to Eclipse CDT where the output of a program (using cout) is written to the "Console" window inside Eclipse.
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...
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