c/c++ 环境配置

1.vscode 下载c/c++ 插件
2. Mingw64(https://sourceforge.net/projects/mingw-w64/files/) 下载安装(直接下载seh结尾的离线直接解压即可)如果要下载在线安装包就得管理员权限运行再科学上网,最后在windows的搜索栏中Mingw64 Install 打开科学上网的下载gcc gdb bin 文件 gcc bin文件和 g++ bin 文件下载安装
3.我的电脑属性–高级系统设置–高级–环境变量–系统变量–PATH–新建–Mingw64的bin目录例如D:/profession/Mingw64/bin
4.vscode中新建一个路径只有英文也不要有空格的文件夹 .vscode 里面加一个.c文件,随便写一串代码 左边虫子 或者 ctrl shift d 再f5 配置任务选C/C++: gcc.exe build active file
5.会自动生成launch.json tasks.json 注意 launch.json miDebuggerPath 不要错

launch .json 配置文件

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "preLaunchTask": "build",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,//这个控制台,true就打开控制台
            "MIMode": "gdb",
            "miDebuggerPath": "D:/profession//mingw64/bin/gdb.exe", // 这里修改GDB路径为安装的mingw64的bin下的gdb.exe路径
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }]
}

tasks.json文件

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build",
            "type": "shell",
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared"
            },
            "windows": {
                "command": "g++",
                "args": [
                    "-ggdb",
                    "\"${file}\"",
                    "--std=c++11",
                    "-o",
                    "\"${fileDirname}\\${fileBasenameNoExtension}.exe\""
                ]
            }
        }
    ]
}