You can create a launch configuration that runs your app in your OS's native terminal/console.
For example I have this very simple test file:
#include <iostream>
int main (void)
{
int num;
std::cout << "Enter number: " << std::endl;
std::cin >> num;
std::cout << num << std::endl;
}
1st, install Microsoft's C/C++ VS Code extension to add support for debugging C++ files.
2nd, create a build task. Open the command palette, find Tasks: Configure Tasks then select a suitable C++ compiler (ex. g++ in my case). If this is the first time you are doing this, VS Code is going to create a .vscode/tasks.json folder in your workspace with a default task. Configure it to build your app, like this:
{
"version": "2.0.0",
"tasks": [
{
"label": "build-test",
"type": "shell",
"command": "/usr/bin/g++",
"args": [
"-g",
"${workspaceFolder}/app/test.cpp",
"-o",
"${workspaceFolder}/app/test"
]
}
],
}
3rd, create the launch task. Open the Debug panel. If you are doing this for the first time and you have no existing launch configurations, just click on the create a launch.json file link:

If you already have existing configurations, open the dropdown and select Add Config.

It should open up the existing launch.json file and show you a popup of which type of launch configuration to use. Select C++ with Launch

Update the configuration like this:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "run-test",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "build-test",
"program": "${workspaceFolder}/app/test",
"cwd": "${workspaceFolder}",
"externalConsole": true,
"args": [],
"environment": [],
"stopAtEntry": true,
"MIMode": "lldb"
}
]
}
The important configs here are "preLaunchTask": "..."
and "externalConsole": true
. The preLaunchTask
should be set to the build task set earlier. The externalConsole
, if set to false
it opens it in the Integrated Console. Since you don't want to run it in the Integrated Console, set it to true
.
Now, whenever you want to run your app, just open the Debug panel, then run your launch task (same name as the name
you set in the launch.json). Note that in the launch.json config, I set stopAtEntry
to true
, to give me a chance to see the external console window and then provide input to the prompt. You can remove it if you don't need it.


If all goes well, it's going to run it by launching an external console.
For more information, the complete guide to setting this up is in VS Code's Configuring C/C++ debugging docs.