How to run C/C++ code using integrated terminal in Visual Studio - c++

How to launch a C/C++ console application using the integrated terminal in Visual Studio instead of launching a separate terminal window?
To clarify more:
When I press the run button right now, this is what happens:
But what I want is something like this (but it must happen when I press the run button), where the output is directed to a terminal inside the visual studio window, without launching a separate window, this will make it easier when debugging because I won't have to switch between multiple windows:

There is a handy VsConsoleOutput extension for Visual Studio 2019 / 2022 that redirects program output into Output window inside of Visual Studio.
However when installing it i've got an exception complaining about incorrect value of InstalledByMsi value somewhere in manifest. The workaround is to manually open downloaded .vsix package (which seems to be a .zip archive) using WinRAR or something, adjust one line in extension.vsixmanifest file and save updated archive.
<Installation AllUsers="true" InstalledByMsi="false">

Related

How to put out a Dos screen once you build in Visual studio?

I'm pretty new to programming and I have built my program a few times. However I can't figure out how to make a Command Window or DOS window show up, even after the build has finished in Visual Studio on Windows.
Suppose you have built your program as a 'Console app' or 'Command-Line app' in Visual Studio. These were choices you made when you first set up your project. Then, running your program from Visual Studio will cause a Command Window (DOS like) to display, and your program will start within this window.
The 'Debug' menu item has 'Start Debugging' and 'Start Without Debugging' - either choice will run your program.
Depending on your version of Visual Studio or your configuration options, Visual Studio may close the console window as soon as the program completes. This is not the default behavior on recent Visual Studio options, but you may miss the Console Window popping up and going away if it is happening to you. Likewise, it may be hidden if the Console Window is not displayed as the top-most Window.

Qt 5.12.1 with Visual Studio2017, build from command line

I linked Qt5.12.1 with Visual Studio 2017.
I want to use Qt's cmd.exe terminal to qmake an application. But, each time I open the Qt's cmd.exe terminal, it tells that
Setting up environment for Qt usage...
Remember to call vcvarsall.bat to complete environment setup!
So I must to run vcvarsall.bat, and only then I can qmake. But I think that is too troublesome. Are there any ideas to solve that problem, so that I wouldn't need to manually run vcvarsall.bat every time I open the cmd.exe terminal.
See existing Qt bug reports about the same issue you have discovered like 1 and 2. Unfortunately, you can't avoid it in Qt 5 until the issue is fixed (if ever).
But I think you could check properties of the Qt command prompt entry (press right mouse button on top of the entry which you clicked to open the command prompt) in Start menu to see which bat file it's calling and edit that script.
I think you could add something like below to the end of the bat file to get vcvarsall called automatically. Check where vccarsall.bat is located in your VS version and depending on your environment use either x86 or amd64. Note that the following line is only to get you an idea how to call another bat file from a bat file, this line sets VS2015 64bit env.
CALL "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64

How to display Visual Studio Console Application output inside the IDE and not in command prompt?

I recently started C++ programming on Visual Studio and I noticed that it always gives me the console output in the command prompt (CMD).
I am a java programmer and I'm used to working with Eclipse and Netbeans. With those IDEs, I was able to see the console inside the IDE and not in a different separate window.
Is there a way to display the console output inside Visual Studio, like Eclipse and Netbeans do?
It's infuriating. I spent hours looking for this. Visual Studio doesn't have command prompt inside the IDE.
They have it for Visual Studio code - Intergrated command prompt. But not for visual studio 2015 Enterprise. So, in other words, microsoft has command prompt terminal inside the free version of visual studio but not for the paid version
Unfortunately, the answer seems to be no.
In Visual Studio, console applications are displayed on the command prompt and not inside Visual Studio itself. Meaning that Console.WriteLine method and similar ones write your output to the console window because your application type is Console Application.
You are able to write output to Visual Studio itself by using System.Diagnostics.Debug.WriteLine as mentioned on MSDN. That will cause the debug output to appear in the Output Window inside Visual Studio. In case you don't see that view, you can choose to show it by Debug => Windows => Output.
You should bare in mind that this is not what you asked for.
This "solution" is helpful just in case you want to debug parts of your code and don't want to open the command prompt but just see the relevant output inside the IDE.
In addition, you won't be able to give input back in this output view.
The most important thing, you will not be able to execute your application correctly outside of your coding environment. So, it will work only on the IDE but you won't be able to see this output when the application is on its own (as it meant to be as a console application).
Another solution, that you might like, is to work with Eclipse.
You said that you are familiar with Eclipse as a Java developer and now you work with C++ and don't get along with Visual Studio so far.
So, you can download Eclipse IDE for C/C++ Developers.
In there you will be familiar with the IDE and you will be able to display your output inside Eclipse without any weird and unnecessary workarounds.

Want to open command prompt when running a program in visual studio community

My visual studio community 2015 are opening a MFC program when I hit RUN. All over youtube, everyone has command promt automatically opening when hitting the RUN or Local windows debugger button. I want to change it to command promt aswell, does anyone have a solution?
(beginner)
It seems you created an MFC project and when you start this, of course you start an MFC program.
If you want a console application use File->New->Project and select the Win32 console project template.
See this MSDN article for more information.

Programs Will Not Run In Visual Studio

My programs will not run in VS. I can code it, but it will not debug or start. It says:
Unable to start program 'C:\Users\Bob\Documents\Visual Studio 2013\Projects\Crankexe2\Debug\Crankexe2.exe'. The system cannot find the file specified.
This goes for all other programs as well.
What is happening?
Why do you open exe file using VS? if you want to open project, please choose sln file. If you want to run this, shortcut ctrl+f5 or using window explorer go to path "C:\Users\Bob\Documents\Visual Studio 2013\Projects\Crankexe2\Debug\" and open file "Crankexe2.exe"