下载MinGW
https://pan.baidu.com/s/1uPtbp0Z9K_UV6fSy_IQvSQ
提取码:4399
然后找一个不会被移动的,路径没有中文的地方下放好
下载VScode
https://code.visualstudio.com
安装C/C++拓展
拓展里面搜C/C++,没有什么后缀,第一个就是
找一个地方新建文件夹,用来写代码
注意所有文件夹都尽可能不要用中文名,有时候路径有中文会出问题
在文件夹下建一个文件夹.vscode
建一个文件叫c_cpp_properties.json
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "D:/C/CodeBlocks/MinGW/bin/g++.exe", // 这改成你自己的路径
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-gcc-x64"
}
],
"version": 4
}
再建一个tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "build",
"command": "D:/C/CodeBlocks/MinGW/bin/g++.exe", // 这改成你自己的路径
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "D:/C/CodeBlocks/MinGW/bin" // 这改成你自己的路径
},
"problemMatcher": [
"$gcc"
],
"group": "build",
"detail": "编译器: D:/C/CodeBlocks/MinGW/bin/g++.exe" // 这改成你自己的路径
},
{
"label": "run",
"type": "process",
"command": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"dependsOn": [
"build"
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared",
"showReuseMessage": true,
"clear": true
}
}
]
}
配置一键运行的快捷键
Ctrl + shift + P 打开搜索,搜Preferences: Open Keyboard Shortcuts (JSON)
然后把下面这段复制进去即可
[
{
"key": "ctrl+r", // 可以根据自己爱好修改,但是需要小心有重复,建议和我一样
"command": "workbench.action.tasks.runTask",
"args": "run"
}
]
配置完成后,创建一个cpp文件,敲好代码后直接Ctrl + R运行,会在终端里面执行代码