Microsoft Visual Studio: how to keep the console open without manually reading input?

I am writing C ++ with Microsoft Visual Studio 2010 Express, and I am wondering if there is a way to display the output of the command somewhere in the IDE instead of the external console window or at least leave this window open.

Reading anything from STDIN will work for a console application, but this is a unit test case, and I do not want to modify the generated main function. Is there another way?

+6
source share
6 answers

Ctrl + F5 for quick testing. The key combination keeps the console open until you close it.

+7
source

I found a solution that is not very elegant, but at least it works. I use a device in my unit testing framework (Boost.Test) that runs system("pause") in a stall method:

 struct Global_fixture { Global_fixture() {} ~Global_fixture() { system("pause"); } }; BOOST_GLOBAL_FIXTURE(Global_fixture) 

Hope you guys can find a better way.

+2
source

In C ++, you want to use: OutputDebugString

+1
source

I think Debug.Write (and related) should do what you are looking for. Writes the VS output window.

0
source

If you use unit tests, you are not debugging, right? So use "Run offut debugging" and the console window will remain open.

In addition, open your own command window and run exe by typing its name.

0
source

In VC ++ use

 Console::WriteLine(L"my error text"); 

Printf will not produce any result. There will be no OutputDebugString. The console will write at the bottom of the output of the test results, so all you need to do is double-click on the test in the "Test Results" window.

0
source

Source: https://habr.com/ru/post/889094/


All Articles