Using windows terminal for executing program in vs code - c++

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",

Related

How to use Windows C++ AttatchConsole with Cygwin terminals

I have a c++ windows application that runs via a GUI. I made a CLI for it to automate some things and this works fine if I use
AllocConsole();
or even
AttachConsole(PID);
as long as it is attaching to a windows CMD terminal.
I want to attach to a Cygwin terminal so I can use Expect to automate some things, but attach console always fails here and results in errors when trying to write to it.
Does anyone know how to make a windows application attach to a Cygwin terminal like this?
Not all cygwin terminals use the windows console. If you are not using a windows console then AttachConsole simply will not help you.
In particular a mintty.exe terminal will not work with AttachConsole because it is not a windows console.

How to run a program from VSCode in Windows CMD terminal? [duplicate]

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.

NetBeans Run in external terminal

I recently installed Arch Linux with XFCE4 desktop environment. I use NetBeans as my IDE. I want to debug a program through NetBeans in an external terminal, but it won't do that. It does not recognize XFCE4 Terminal, and will not run gdb within it.
Is there a way that I can permanently set NetBeans to debug/run my programs in XFCE4 Terminal (aka, add it to "run in external terminal")?
Also, I'm using NetBeans 8.0-1, and gcc 4.9 (all the latest and greatest with Arch! :), if that helps at all.
If you need any more details, please ask.
After installing Konsole (a KDE terminal), I was able to make it work! Using XFCE as my default still, though, since it's a really nice terminal.
Gnome terminal did not work. When I opened it, it did not show any text, and I couldn't verify input or output as a result.

How to let terminal window be closed automatically in a linux Console Application when run by IDE

When I compile a C++ console application in a Linux IDE like Qt Creator or code::blocks, the terminal window (unlike Windows Console) waits for pressing Enter to be closed. Codes like exit(0) and system("exit") don't work.
Is there any code or option in Qt IDE to let the terminal window (xterm or konsole) be closed automatically after execution.
It is actually made for you. If you build executable of your application and run it from terminal (outside of IDE), it (your application... not the terminal) will close after execution (return in main).
CodeBlocks uses smth called cb_console_runner to run executables and wait for ENTER to close terminal. I am not sure how is it possible to make it work without cb_console_runner
EDIT: In codeBlocks... remove/rename cb_console_runner in /bin and it is solved:)
to make it easier: run this command:
sudo mv /bin/cb_console_runner cb_console_runner_s
In QtCreator in Project->Run settings
uncheck "Run in Terminal"

AIR NativeProcess API

I use nativeprocess api in AIR to launch a c++ console app. The console app runs correctly but does not appear, but I want it to be visible and user be able to interact with it. How can I achieve that?
Instead of launching your executable directly, you'll need to launch your platform's terminal application (on Windows, that's CMD.exe, on OS-X it's Terminal.app, and on unix/linux it's xterm).
By default, the terminal application will run an interactive shell prompt, but you can use command-line arguments to tell it to execute any other program instead. In this case, you'll want to tell it to execute your C++ console application.
On Windows, this might look something like this:
CMD.exe /K C:\path\to\your\app.exe
on OS-X, it's a little more complicated. Here's a related S.O. post ( Running a command in a new Mac OS X Terminal window)