需要的两个文件
.vscode
目录下
- tasks.json
{"tasks": [{"type": "cppbuild","label": "C/C++: g++.exe 生成活动文件","command": "C:/MinGW/bin/g++.exe","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "C:/MinGW/bin"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}],"version": "2.0.0"
}
- c_cpp_properties.json
{"configurations": [{"name": "Win32","includePath": ["${workspaceFolder}/**"],"defines": ["_DEBUG","UNICODE","_UNICODE"],"windowsSdkVersion": "10.0.19041.0","cStandard": "c11","cppStandard": "c++11","intelliSenseMode": "gcc-x86","compilerPath": "C:/MinGW/bin/g++.exe"}],"version": 4
}
然后使用code run插件直接运行即可