I start to work in VSCode using C++.
I use Ubuntu 18.04, g++ compilet 7.4.0, VSCode 1.39.2
I create simple test.cpp
:
#include <string>
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
/* code */
cout << "Hello, world";
getchar();
return 0;
}
And configure my launch.json
:
{
// 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": "g++ build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "MyDefaultTask",
"miDebuggerPath": "/usr/bin/gdb"
}
]
}
and task.json
:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "MyDefaultTask",
"command": "/usr/bin/g++",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
All is OK when using debug mode(F5):
but I can't see output when running Task (Ctrl+Shift+B):
How to see the program output (and console, because I want to use Keyboard input in my program)?