C语言运行环境安装

安装C语言运行环境

百度云盘:https://pan.baidu.com/s/1CWqcUz2-T8p3bOOX6pHh5g

提取码:kp8t

下载.NET Framework 4.7.2:  https://dotnet.microsoft.com/download

安装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进行标记,其中gccg++cc++编译器 
选择完全部想要安装的项后点击左上角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: https://go.microsoft.com/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\\gdb.exe",
                "preLaunchTask": "gcc",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ]
            }
        ]
    }

     

  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 

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 -o study.exe

  1. 执行

>.\study.exe

 

参考 

https://blog.csdn.net/Realoyou/article/details/82051002

https://blog.csdn.net/qq_28581077/article/details/81380341

你可能感兴趣的:(C,vscode)