类型:调试器
"externalConsole":true
中启用launch.json
,但徒劳无功。实际上,当我这样做时,会出现一个外部控制台,但由于光标闪烁,所以似乎是“错误的”,但是当我写进去时,什么也没发生。以下是“错误的”外部控制台的屏幕截图:
这是我的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": "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"
}
]
}
这是我尝试执行的代码示例:
#include<bits/stdc++.h>
using namespace std;
int main()
{
cout << "Hello";
string name;
cin >> name;
cout << "Hello " << name;
return 0;
}
问题已解决。我只需要进入VSCode调试界面,以便外部控制台可以在其中编写代码。