1、下载vs code 官网地址:https://code.visualstudio.com/
2、需要在vs code中显示中文界面的话需要安装中文插件:
3、同样方式安装Code Runner,运行插件
4、再安装c/c++插件
5、windows系统下安装Mingw-w64 ,是c/c++编译器,windows版本的gcc
下载地址:https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/
下载安装后,配置环境变量 Path中添加Mingw-w64的bin目录 ,比如我的是:D:\rruanjian\mingw64\bin
控制台输入gcc -v 看是否成功
注意:配完环境变量后一定要重启vscode,否则不生效
6、Shift+Ctrl+P,
点击后配置
7、创建一个文件夹,在里面创建一个文件:
#include
int main()
{
printf("hello world!");
}
8、按F5,在文件中会生成同名的exe文件,可以再控制台通过 .\ 文件吗.exe 执行,例如
9、或者用Code Runner执行的吗,就是打开文件,然后右键 run code ,在下面的输出看结果就行了,或者F5调试启动
launch.json配置文件 miDebuggerPath:改成自己的路径
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc - 生成和调试活动文件",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\rruanjian\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "C/C++: gcc build active file"
}
]
}
task.json配置文件 command 路径改成自己的路径
{
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc build active file",
"command": "D:/rruanjian/mingw64/bin/gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"version": "2.0.0"
}
大概就是这个了,以后有别的再补充