C++ Terminal Not Working in Visual Studio Code

0

I have a C++ program. This program not working. I changed "externalConsole": false to "externalConsole": true, it works and it gives me console. But I want to run with "externalConsole": false. Is there a way to do this? Relevant outputs is below.

Program (asd.cpp)

#include <iostream>
using namespace std;

int main()
{
    int x  = 1525, z;
    cout << "x number is " << x << endl;
    cin >> z;
    cout << "z number 2 is " << z << endl;
    getchar();
}

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": "(gdb) Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/asd.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "miDebuggerPath": "C:/MinGW/bin/gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

Terminal

Windows PowerShell

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Users\hakan\projects\onecpp>  & 'c:\Users\hakan\.vscode\extensions\ms-vscode.cpptools-1.3.0-insiders4\debugAdapters\bin\WindowsDebugLauncher.exe' '--stdin=Microsoft-MIEngine-In-emhvpzpo.syb' '--stdout=Microsoft-MIEngine-Out-dht4nkur.p5d' '--stderr=Microsoft-MIEngine-Error-cpkcr2pw.mzq' '--pid=Microsoft-MIEngine-Pid-v2fsb4cd.no1' '--dbgExe=C:/MinGW/bin/gdb.exe' '--interpreter=mi' 
PS C:\Users\hakan\projects\onecpp> 

Debug Console

=thread-group-added,id="i1"
GNU gdb (GDB) 7.6.1
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "mingw32".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Warning: Debuggee TargetArchitecture not detected, assuming x86_64.
=cmd-param-changed,param="pagination",value="off"
=cmd-param-changed,param="args",value="2>CON 1>CON <CON"
[New Thread 9284.0x16f4]
x number is 1525
z number 2 is 1013
The program 'C:\Users\hakan\projects\onecpp\asd.exe' has exited with code 0 (0x00000000).

I make a program to enter data, I cannot enter data and it writes 1013.

Build is working: Build finished successfully.

c++
visual-studio-code
vscode-debugger
asked on Stack Overflow Apr 8, 2021 by en0ndev • edited Apr 8, 2021 by en0ndev

1 Answer

0

The setting "externalConsole": false is deprecated. Try using "console": "integratedTerminal" with the latest version of Visual Studio Code instead. For me console input in the integrated terminal works then.

answered on Stack Overflow Apr 8, 2021 by Eric

User contributions licensed under CC BY-SA 3.0