VS Code environment configuration-c/c++ (MinGW compiler)

First download VS Code (Baidu Yisou directly jumps out of the official website, scroll down to find the download address and select the corresponding version to download)

Open the downloaded VS Code, install two commonly used and necessary extensions, the first step is the shortcut key Ctrl + shift + x Open the command box to directly open the extension store.

(1) Search Chinese, click the first Simplified Chinese version

(2) Search for c/c ++ , select this version to install (I installed it here)

Download MinGW editor and configuration

Official website:


Both download methods are available, in short, choose the one that matches your computer configuration, generally x86_64-win32-seh

Be sure to copy the downloaded path, then open the control panel that comes with Windows, click System and Security, System, Advanced System Settings

Add your download path here

Check if the configuration is successful

win + R to bring up the run box, enter cmd and press Enter, enter gcc -v and the following code text appears, then it is successful

Open VS Code and create a new VSCODE folder (I have already built it here)

And create a folder .vscode under this folder, and then create the following three files under this folder. The creation method is to right-click .vscode and click the first new file…, and then directly enter c_cpp_properties.json that is The creation of the first file can be completed, and the subsequent steps are the same.

Complete the preparatory work for creation as shown in the figure below

Let’s populate the content of these three files

1. c_cpp_properties.json

    "configurations": [
          "name": "Win32",
          "includePath": ["${workspaceFolder}/**"],
          "defines": ["_DEBUG", "UNICODE", "_UNICODE"],
          "windowsSdkVersion": "10.0.17763.0",
          "compilerPath": "E:\VS\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\bin\g + + .exe", //Modify to your own path, the suffix remains unchanged
          "cStandard": "c11",
          "cppStandard": "c++17",
          "intelliSenseMode": "${default}"
      "version": 4

2. launch.json

    // Use IntelliSense for relevant properties.
    // Hover to see descriptions of existing properties.
    // For more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
            "name": "g + + .exe build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "E:\VS\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\bin\gdb. exe",//Similarly modify to your own path
            "setupCommands": [
                    "description": "Enable tidy printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
            "preLaunchTask": "task g + + "

3. tasks.json

    "version": "2.0.0",
    "tasks": [
        "type": "shell",//Here is the shell to pay attention to
        "label": "task g + + ",
        "command": "E:\VS\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\bin\g + + .exe",//self path
        "args": [
            "E:\VS\vscode",//self path
        "options": {
            "cwd": "E:\VS\x86_64-8.1.0-release-win32-seh-rt_v6-rev0\mingw64\bin"//From the path
        "group": "build"

After completing the above steps and saving them, you’re done. Next, we create a qiuhe.c / qiuhe.cpp, write the following code and press Ctrl + F5 to run it. Just select MinGW for the first run

#include <stdio.h>
int main()
    int num1 = 0;
    int num2 = 0;
    int sum = 0;
    scanf("%d %d", &num1, &num2);
    sum = num1 + num2;
    return 0;

operation result

If you encounter problems, you can contact the blogger to help you solve them by private message, thank you for watching!