从mingw64下载安装包
vscode 安装扩展,输入C/C++
安装第一个
打开一个文件夹,编写一个cpp文件
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
cout << "hello" << endl;
return 0;
}
按F5
可以打开lauch.json
和tasks.json
具体设置如下
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc.exe - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\Cpp\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "g++"
}
]
}
{
"tasks": [
{
"type": "cppbuild",
"label": "g++",
"command": "g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:\\Cpp\\mingw64\\bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "Task generated by Debugger.",
"presentation": {
"panel": "new" //默认为“shared“表示共享,改成new之后每个进程创建新的端口
}
}
],
"version": "2.0.0"
}
在return 0
前面加个断点
按F5
可以看到跳出小黑框,显示hello