C语⾔运⾏环境安装安装C语⾔运⾏环境
提取码:kp8t
安装VS CODE
安装插件
1. Cpptools
2. C/C++(就是有些教程⾥的cpptools)
3. C/C++ Snippets(Snippets即重⽤代码块)
4. C/C++ Advanced Lint(vscode-c-cpp-flylint)(Lint即静态检测)
5. Code Runner
6. Include Autocomplete
安装mingw-get
windows下调试仅⽀持 Cygwin 和 MinGW。
安装以下拓展包
1. All Packages/MinGW/Mingw32-gcc bin
2. All Packages/MinGW /Mingw32-gcc-g++ bin
3. All Packages/MinGW/MinGW Base System/Mingw32-gdb bin
选中⼏个需要的项右键Make for Installation进⾏标记,其中gcc和g++为c和c++编译器选择完全部想要安装的项后点击左上⾓Installation菜单下的Apply Changes应⽤修改
配置系统环境变量path
控制⾯板\所有控制⾯板项\系统\系统设置\环境变量\系统变量\path
添加“;D:\MinGW\bin” // MinGw安装路径
配置vscode
1. 新建⽂件夹(d:\LYH20190317002)
2. 新建⽂件study.c
3. 添加断点
1. 点击调试,跳出跳出⼀个launch.json的⼀个配置⽂件,并修改
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: go.microsoft/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceRoot}/${fileBasenameNoExtension}.exe", // enter program name, for example ${workspaceFolder}/a.exe "args": [],
"stopAtEntry": false,
"cwd": "${workspaceRoot}", // ${workspaceFolder}
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "D:\\MinGW\\bin\\",
"preLaunchTask": "gcc",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]系统变量path修改了怎么恢复
}
]
}
1. program⼀项,指明了需要运⾏的⽂件
2. miDebuggerPath是我们安装gdb的路径,调试的⼆进制⽂件(可执⾏⼆进制⽂件也叫命令)
3. preLauchTask配置的意思是⽤gdb去调试 program参数指定的⼆进制⽂件
1. 在.vscode⽂件夹下新建tasks.json⽂件
{
"version": "2.0.0",
"command": "gcc",
"args": ["-g","${file}","-o","${fileBasenameNoExtension}.exe"]
}
调试:F5
⼿动编译
1. 新建⽂件:
#include <stdio.h>
int main()
{
int n;
printf("This is a test file!\r\nInput a number: "); scanf("%d",&n);
printf("The number is %d",n);
return 0;
}
1. 编译
> gcc -g study_1.c -
1. 执⾏
>.\
参考
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论