Vscode-cpptools: How to prevent console window from closing when I Start Without Debugging?

Created on 18 Jul 2018  路  2Comments  路  Source: microsoft/vscode-cpptools

Describe the bug

  • OS and Version: Windows 10
  • VS Code Version: 1.25.1
  • C/C++ Extension Version: 0.17.6
  • Other extensions you installed (and if the issue persists after disabling them): not relevant
  • A clear and concise description of what the bug is.

To Reproduce
tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build Debug",
            "type": "shell",
            "command": "g++",
            "args": [
                "-g3",
                "-O0",
                "-std=c++17",
                "main.cpp",
                "-o",
                "bin/pool.exe"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
C:\>g++ --version
g++ (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

Steps to reproduce the behavior:

  1. Run a C++ program without debugging with Ctrl+F5

A console windows appears, the program executes, and then the console window is immediately closed. How do I prevent it from closing? Alternatively, how do I run a program in such a way that output is redirected to the VS Code's output windows?

debugger

All 2 comments

@mmatrosov There currently isn't a way to keep the window open except to set a breakpoint at the end of main() and then inspect the data.

We haven't implemented having output in the VSCode output window yet.

You can use "externalConsole": false in launch.json to have your output be directed to the integrated terminal.

Was this page helpful?
0 / 5 - 0 ratings