闲来无事,编写一个C语言程序,代码如下:

#include using namespace std;int main(){int a, b;cout <> a;cout <> b;cout << "a+b=" << a + b << endl;return 0;}

想通过VScode调试一番,发现出现了以下的提示

在网上找了许多方法,都没有成功,最后打算自己慢慢研究研究。。。

我按照提示打开了launch.json文件

{"version": "0.2.0","configurations": [{"name": "C/C++ Runner: Debug Session","type": "cppdbg","request": "launch","args": [],"stopAtEntry": false,"externalConsole": true,"cwd": "c:/HIT/WangDao/DS","program": "c:/HIT/WangDao/DS/build/Debug/outDebug","MIMode": "gdb","miDebuggerPath": "gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}]}

通过观察,发现问题出现在“program”,我输入一定的字符,发现有自动提示功能,根据提示,将JSON文件中的program修改为(其他行不变),也就是说,将路径改为.exe文件所在的位置:

"program": "c:/HIT/WangDao/DS/output/${fileBasenameNoExtension}.exe",

再进行调试,就成功了