在调试C++时在VSCode中向std::cin传递输入的问题

在调试C++时在VSCode中向std::cin传递输入的问题

类型:调试器

OS: Windows 10VS description : 1.42.1C/C++扩展版本:0.26.3--没有安装其他扩展< Code >H19--我所面临的主要问题是无法使用VSCode C++调试工具将输入传递给std::cin<>E 211。我尝试了我在网上找到的不同的东西,主要是在launch.json中启用launch.json,但没有成功。事实上,当我这样做时,会出现一个外部控制台,但它似乎“被窃听”了,因为它有一个闪烁的光标,但是当我写入它时,什么都不会发生。

下面是“窃听”外部控制台的屏幕截图:

https://imgur.com/a/sVA6LCJ

下面是我的launch.json配置:

代码语言:javascript复制{

// 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"

}

]

}下面是我正在尝试执行的代码示例:

代码语言:javascript复制#include

using namespace std;

int main()

{

cout << "Hello";

string name;

cin >> name;

cout << "Hello " << name;

return 0;

}

相关阅读