1.首先安装一下c++插件

如图
重启vscode
2.写个hello world 压压惊 main.c
```
#include<stdio.h>
int main(void) {
printf("hello world!\n");
}
```
3.command+shift+b

点击创建生成任务

创建tasks.json文件

修改tasks.json
```
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"src/main.c",
"-o",
"main"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
```
4.配置调试launch.json

修改launch.json
```
{
"version": "0.2.0",
"configurations": [
{
"name": "test Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "lldb"
}
]
}
```
5.开始调试 (记得调试之前要command+shift+b)
