理论上所有C语言代码都可以在C++环境下运行,所以直接配置C++环境,VScode属于轻量编辑器很快速的就可以打开,内存量也小,很实用,但是想运行C,python等语言必须配置环境,对于新人太糟糕了,哎哎哎哎,可是它真的很轻盈,谁又不喜欢内存瘦子呢。
对于初学者能用就行,有问题直接在下面问,不废话,上才艺!(一定要看到文章底部)
1. VScode下载与安装(图文教程)
下载网址: https://code.visualstudio.com/.
(1)点击下载即可
(2)双击刚才下载的文件
(3)选择我接受协议,点击下一步
(4)都选,点击下一步
(5)点击安装
(6)打开桌面的VScode,改成中文版
输入chinese,点击install
点击重启即可
**
好滴,中文版完成。**
2.VScode配置C++环境
安装好了,随便创建一个.c文件并不能编译运行,需要配置编译文件与添加编译器就行,不用管这是啥,以后都明白的,直接跟着下面的步骤来。
(1)点击下载C++插件,和中文版一样
(2)下载mingw,网上的都很复杂且多,而且下载慢,这里直接上链接
链接:https://pan.baidu.com/s/1RTEpAvUor-zOnIIvbAJ8tg .
提取码:t2n1
得到一个解压包,解压一下,放到任何一个文件夹都可以,没个人的安装习惯不同,比如我放在了D:\Zinstallation\study,你可以放在D,E盘任何一个文件夹,但是一定要记得路径
(3)配置环境变量
在搜索中打开编辑系统环境变量
点击
)
找到path,点击编辑
点击新建
输入跟你存放MinGw的路径有关,比如我的是 D:\Zinstallation\study\MinGW\bin一定要根据自己放的MinGw文件夹位置来
点击确认
(4)配置C++文件(重点)
1.随便位置新建文件夹VScodeCpp(也可以改其他名字),打开VsCode文件夹选择打开文件夹VsCodeCpp。
2.点击左上角在这个文件夹在此建立名字为.vscode文件夹,这个名字不能随意,点别忘了。
3.点开.vscode文件夹,在此文件夹内创建如下四个文件
(1)名字为:c_cpp_properties.json,注意这个文件需要改内容,其中D:/Zinstallation/study/MinGW/,改成自己存放MinGw的位置。
{"configurations":[{"name":"Win32","includePath":["${workspaceRoot}","D:/Zinstallation/study/MinGW/include/**","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed","D:/Zinstallation/study/MinGW/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}","D:/Zinstallation/study/MinGW/include/**","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed","D:/Zinstallation/study/MinGW/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"]}}],"version":4}
(2)launch.json注意这个文件需要改内容,其中D:/Zinstallation/study/MinGW/,改成自己存放MinGw的位置。
{"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":[],"console":"externalTerminal"},{"name":"(gdb) Launch","type":"cppdbg","request":"launch","program":"${workspaceFolder}/${fileBasenameNoExtension}.exe","args":[],"stopAtEntry": false,"cwd":"${workspaceFolder}","environment":[],//"externalConsole": true,"externalConsole": true,"MIMode":"gdb","miDebuggerPath":"D:/Zinstallation/study/MinGW/bin/gdb.exe","preLaunchTask":"echo",//这里和task.json的label相对应"setupCommands":[{"description":"Enable pretty-printing for gdb","text":"-enable-pretty-printing","ignoreFailures": true
}]}]}
(3)settings.json,这个文件内容不需要更改
{"C_Cpp.intelliSenseEngineFallback":"Disabled",//需要添加的"C_Cpp.intelliSenseEngine":"Tag Parser",// 需要添加的}
(4)tasks.json,这个文件内容不需要更改
```c
// 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
}}
记得保存,以后在VsCodeCpp文件夹建立.c或者.cpp文件即可,来建立test.cpp试试能不能运行。
以后在VsCodeCpp建立.c或者.cpp文件即可
如果有问题请在下方留言,真的不会请私聊我,我帮你装。
3.才艺展示
说好的才艺部分必须得展示。不用谢我,不要私聊我这些哪来的,也不要再评论区诽谤我,我是正规博主昂。
版权归原作者 笨拙的程序猿 所有, 如有侵权,请联系我们删除。