Type: Debugger
- OS: Windows 10
- VS Code Version: 1.42.1
- C/C++ Extension Version: 0.26.3
- No other extensions installed
- A clear and concise description of what the bug is:
The main issue that I have is the inability to pass input to std::cin using VSCode debugging tool for C++. I tried different things that I found online, the main one was enabling
"externalConsole":truein thelaunch.json, but in vain. In fact, when I do that, an external console appears, but it seems 'bugged', since it has a blinking cursor, but when I write into it, nothing happens.
Here is a screenshot of the 'bugged' external console:
https://i.sstatic.net/RkrT6.jpg
Here is my launch.json configuration:
{
// 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++.exe build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++.exe build active file"
}
]
}
Here is the code sample that I am trying to execute:
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout << "Hello";
string name;
cin >> name;
cout << "Hello " << name;
return 0;
}
2 Answers 2
Just do "externalConsole":true in the launch.json under the .vscode in your working directory. After that an external Terminal Window will appear, enter the input after you hit STEP OVER while on CIN!
Comments
Problem solved. I just needed to step over in VSCode debug interface so that the external console let me write in it.
Comments
Explore related questions
See similar questions with these tags.
cin? When was the last timecinworked in VS?cinworks fine in 'normal' mode (without the debugging tool). The problem occurs when I use the debugging tool.