下载地址:https://code.visualstudio.com/
链接: link.
并进行安装,安装成功后,打开VSCode;
先按ctrl+k;再按ctrl+t,选择喜欢的主题
选定后,点击即可:
① 单击左侧导航栏第五个图标—>输入Chinese—>选择中文简体(繁体)—> 单击install进行安装(当install变成uninstall说明安装完成)
② 完成后,重启,即可得到 中文界面
单击左侧导航栏第五个图标—>输入c—>选择C/C++这个—> 单击install进行安装(当install变成uninstall说明安装完成)
下载完成后重启VSCode。
官网下载:点击进入
官网下载速度较慢,所以可以用百度网盘来下载
链接:https://pan.baidu.com/s/1NDmsIN522OGMlQArJxyvuQ?pwd=ie2b
提取码:ie2b
复制该文件夹的地址,方法:单击选中文件夹,点击[复制路径],即可将地址复制到剪切板
① 双击【此电脑】---- 点击【属性】---- 进入到下面这个界面,单击【高级系统设置】;
② 进入到 系统属性界面 ---- 点击【环境变量】,进入环境变量页面;
③ 找到【系统变量】中的【Path】变量 ---- 双击打开后,将刚刚复制的地址添加进去 ---- 点击【确定】;
④ 之前弹出的所有页面都点击【确定】;
⑤ 最后测试环境配置是否成功:
Win+R快捷键打开运行窗口,输入【cmd】,回车打开cmd.exe;
在cmd.exe中输入命令【gcc -v -E -x c++ -
】,回车
如果运行结果如下图这样,说明配置成功✌。
1、新建一个文件夹作为C语言项目文件,在VSCode中打开该文件夹,在这个文件夹中新建一个hello.c
文件(名称随意取,但后缀要是.c)
2、再建一个【.vscode
】文件夹(注意:前面那有个点)---- 在里面新建三个文件,c_cpp_properties.json、launch.json、tasks.json;
c_cpp_properties.json
:将以下代码复制到该文件中;{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceRoot}",
"C:/Program Files/mingw64/include/**",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
],
"defines": [
"_DEBUG",
"UNICODE",
"__GNUC__=6",
"__cdecl=__attribute__((__cdecl__))"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": "",
"path": [
"${workspaceRoot}",
"C:/Program Files/mingw64/include/**",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed",
"C:/Program Files/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
]
}
}
],
"version": 4
}
launch.json
:将以下代码复制到该文件中;{
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) Launch",
"type": "cppvsdbg",
"request": "launch",
"program": "cmd",
"preLaunchTask": "echo",
"args": [
"/C",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"&",
"echo.",
"&",
"pause"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole":true
},
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Program Files\\mingw64\\bin\\gdb.exe",// 自己电脑的gdb
"preLaunchTask": "echo",//这里和task.json的label相对应
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
tasks.json
:将以下代码复制到该文件中;{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "echo",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"${file}",
"-o",
"${fileBasenameNoExtension}.exe",
"-fexec-charset=GBK"//解决中文乱码
]
}
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": false,
"panel": "shared",
"showReuseMessage": true,
"clear": false
}
}
c_cpp_properties.json
:
将下图中框选的内容进行修改,改为自己的安装路径——也就是我们下载的编译器的地址;
【方法】:将我们下载好的MinGW-W64 GCC解压后的文件中的mingw64
文件的地址复制下来,替换代码里所有的 【"C:/Program Files/mingw64】部分
ps:我的更改部分:"D:/BaiduNetdiskDownload/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64
tasks.json
:无需更改
在之间建立的hello.c
文件中写个简单程序,并运行;
运行结果如下:
运行成功,因此VSCode在C语言环境下的配置完成~撒花 ★,°:.☆( ̄▽ ̄)/$:.°★ 。