I have a Console application open in VS Code. When I press Ctrl-F5, the output of my program is displayed in a DEBUG CONSOLE window, along with other text.
How do I get Visual Studio code to launch my program in a new console window?
As documented here this can be achieved using this setting:
"console": "externalTerminal"
The settings file is in the solution directory: .vscode/launch.json .
When you're just using Tasks and not Launchers, you can follow the advice here.
For me on Linux, I changed my shell command in VSCode from command to gnome-terminal -e command. That did the trick; that's all I had to do.
Note that if you do this you can get rid of the presentation option set from your task.
Related
everyone. I'm kind of new in this field. So bear with it. I'll try to be as specific as I can:
let's say when I run a code(c++ file) in VScode it runs that code on VScode's internal terminal..like this => VScode
but I want that code to run on my Window's CMD like "CodeBlocks" software. Like this => CodeBlocks
but I don't know how to do it in VScode. I mean, when I click on 'run' button it should execute that code on CMD. I tried many ways but it's not working. Help please and thanks in advance.
VSCode has a built-in terminal. That is why in the first case(first image in your question) you see the output as it is. If you don't want to use the built in terminal provided by VSCode then i suggest you open a standalone/separate terminal. And then cd into the project you want to build/compile and then compile the program from there.
Basically, open a terminal externally then go(cd) to your workspace folder and finally compile and run in the external terminal.
I use vscode for writing and executing my C++ programs, I use the integrated terminal in vscode for compiling & running the programs(using coderunner) but I want to run my programs in the Windows terminal by default each time I run the program in vscode. Can anyone please help me out with this ?
If you want to use Windows Terminal more easily, you can open Windows Terminal in quake mode. The keybind is win+` by default. This could avoid using the integrated terminal at all, if you prefer.
You could also use the integrated terminal to pass your command to Windows Terminal. Replace ping learn.microsoft.com with the command you want to execute. You can then send build and run commands to Windows Terminal with wt.exe:
wt ping learn.microsoft.com
Alternatively, you can configure debugging behavior for when you press F5. First, configure launch.json to launch your configured external terminal:
"console": "externalTerminal",
Then configure VS Code settings to set the external terminal for your OS in settings.json:
"terminal.external.windowsExec": "wt.exe",
I have a Console application open in VS Code. When I press Ctrl-F5, the output of my program is displayed in a DEBUG CONSOLE window, along with other text.
How do I get Visual Studio code to launch my program in a new console window?
As documented here this can be achieved using this setting:
"console": "externalTerminal"
The settings file is in the solution directory: .vscode/launch.json .
When you're just using Tasks and not Launchers, you can follow the advice here.
For me on Linux, I changed my shell command in VSCode from command to gnome-terminal -e command. That did the trick; that's all I had to do.
Note that if you do this you can get rid of the presentation option set from your task.
I want to compile C++ in VSCode. I followed the walkthrough here
When I run the example program in VSCode terminal, nothing is output into the terminal. I tried in powershell and in cmd using the dropdown in VSCode terminal window.
When I run the .exe from a standalone cmd terminal, it works fine. Could the problem be something about not knowing how to write the output? I'm guessing the program runs but just doesn't know where to output.
I opened VS code before adding mingw to my PATH. I simply had to restart VS code. I really figured each time I opened a new terminal in VS Code, it would.. open a new terminal. Perhaps they do some kind of virtual terminal and it's really all one terminal from launch? Who knows. Either way, restart VS code.
Command Prompt method :
first changer the directory to where file is located.
g++ -o program Menu-driven-program-DAA.cpp&program.exe
Running Cpp program through powershell terminal in vscode:
g++ -o program Menu-driven-program-DAA.cpp
.\program.exe
I've mentioned both the commands in vscode powershell terminal seperately because it throws an error
Note:- try gcc instead of g++ if it doesn't works for me only g++ did.
I encountered the same problem and by pure chance following worked in my case: When I opened VSC from a GIT shell via 'code .', I didn't get any output from a shell within VSC. But when I opened VSC from windows command prompt via 'code .' and executed the same file again and it worked.
I am trying to run a simple C++ program on CLion. The problem is that when I try to compile and run it, it shows the result in the application console. I want to run on the System console like the Visual Studio runs the output of the console apps. Is there a way of doing this. I use MINGW compiler.
You can use an external terminal, do these steps.
(top menu) run\ edit Configurations
tick 'run in external console'
Well, if anyone is still around wanting to open an external cmd window on run, there is a way to do it on Windows as well:
Go to Run > Edit Configurations
For the executable select C:\Windows\System32\cmd.exe
For program arguments use: /c "start cmd.exe #cmd /k "ProjectName.exe""
For working directory set the cmake debug (or release) folder
Save and select the profile from the dropdown right next to the run button
Note: In the third step /k can be replaced with /c to make the window close after the program is run (with /c its more like visual studio and with /k its more like code blocks)
I am not sure about Windows but in linux you can do it using this answer.
You might be able to change the gnome-terminal to cmd if you are using windows but you will probably need to change the "Program Arguments" too.
the above answer works fine in windows also. In working directory you can set this $CMakeCurrentBuildDir$
enter image description here