简体   繁体   中英

VSCode - cannot enter input into console while debugging C++

I know this was asked many times before, but none of the solutions have worked for me.

I am trying to debug a single C++ file on Visual Studio Code on Windows. Running and debugging works fine. However, when I try to debug a program that asks for user input (for example using cin or scanf() ), the process starts and just hangs. The program is waiting for me to input something, however the integrated terminal does not let me type anything in.

One possibility is to run debug in an external terminal, but the problem with the external terminal is that it closes immediately when the program finishes, so I cannot see the result.

Is there an option in launch.json or maybe an extension that would help solve my issue?

Here's my launch.json file:

"name": "g++.exe - Générer et déboguer le fichier actif",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
  {
    "description": "Activer l'impression en mode Pretty pour gdb",
    "text": "-enable-pretty-printing",
    "ignoreFailures": true
  }
],
"preLaunchTask": "C/C++: g++.exe build active file"

Reinstalling MinGW seems to have solved the issue for me. I used the installer from it's SourceForge page.

I do not know what original the issue was, but now it is possible to type into the terminal when in debug mode. I suspect the issue was with my gdb installation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM