search
HomeComputer TutorialsComputer KnowledgeHow to configure VS Code for Microsoft C++

I chose C as my first language when I embarked on my programming journey. C/C++ is often regarded as the starting point of the programming world. In this article, we'll look at how to configure VS Code for Microsoft C as this can present some challenges since C requires a compiler and interpreter to run your code correctly.

如何配置VS Code for Microsoft C++

How to configure VS Code for Microsoft C

To configure VS Code for Microsoft C++, follow the steps mentioned below.

  • Download and install Microsoft Visual Studio Code
  • Install C extension
  • Installing and setting up the MinGW compiler
  • Set path and configure environment variables
  • Let’s talk about it in detail.

    1]Download and install Microsoft Visual Studio Code

    First, visit code.VisualStudio.com to download the VS Code application for your operating system. After installation, make sure Add to Path is checked in the options (requires shell restart).

    2]Install C extension

    如何配置VS Code for Microsoft C++

    Now that we have Visual Studio Code installed on our computer, it's time to get the correct extension, which will tell Visual Studio Code, "Hey, this is a C code!".

    To perform the same steps, first open VS Code, select the Extensions icon in the top menu or press Ctrl Shift X. Then, enter "C/C" in the search bar, and the system will automatically search for related extensions. Just click on the C/C extension and then click "Install".

    After installing the C/C extension, you need to install the Code Runner extension. This tool makes it easy for us to run code snippets or files. But note that we also need to install the compiler next.

    3]Install and set up the MinGW compiler

    如何配置VS Code for Microsoft C++

    Our computer systems are built using electronic switches and cables that can only work with the binary numbers 1 and 0. In order for your computer's central processing unit (CPU) to understand your high-level C code, you need a compiler that can translate it into machine language. For this reason, we will install and configure the MinGW compiler.

    First, let’s download the MinGW compiler from Sourceforge.net. You can get the compiler for free. After installing the MinGW installer, go to the download folder, run the installer and follow the steps mentioned below.

  • You need to follow the on-screen instructions to complete the installation process.
  • After the installation is complete, click Continue.
  • This will launch the MinGW Installation Manager, you need to right click on the option and select Mark for Installation. Ideally, you only need a C compiler, but we want you to be future-proof, so it's best to install all required compilers.
  • After selecting all the checkboxes, click Install in the upper left corner of the screen and select Apply changes to apply.
  • Finally, let this step do its work and install all the packages we just checked.
  • Once the MinGW package is installed, you cannot start coding immediately, we need to set and configure environment variables.

    4]Set path and configure environment variables

    如何配置VS Code for Microsoft C++

    Next, we need to set the path and configure environment variables. To perform the same operation, first open File Explorer and then go to the local disk C>Mingw&>Bin. Then copy the location, it should look like C:\MinGWbin. Make sure to paste it somewhere accessible.

    To configure environment variables, search for and open "View advanced system settings". In the Advanced tab, click Environment Variables. Then you have to click on the path from the Environment Variables section and then click on Edit. Then click New, enter the path we asked you to copy earlier, and finally click OK. Finally, click OK and close the System Properties window.

    如何配置VS Code for Microsoft C++

    In this way, we configure environment variables for our compiler. To confirm, open a command prompt as an administrator and run the following command.

    G++--版本

    If you receive the following message or a similar one, you are ready to get to work.

    G (MinGW.org GCC-6.3.0-1)6.3.0Copyright (C) 2016 Free Software Foundation, Inc.

    Finally, you can start coding.

    Read: Enhance your code on Visual Studio Code with extensions

    How to run C in Microsoft Visual Code?

    To run C in Microsoft Visual Code, you need to install the C extension and other basic extensions, then download and configure the compiler, you can use Clang or MinGW compiler. We have previously detailed how to install C and configure the compiler.

    Read: The Best C Extensions for Visual Studio Code

    How to set the default code for C in Visual Studio Code?

    To set default code in VS Code, first press Ctrl Shift P to open the command palette, then search for "> Configure User Fragments" and click on it. Next, search for "cpp.json" and open the file. Finally, replace the comments in the file with the snippet code that has been copied to the clipboard.

    Also Read: Best Free C IDE for Windows.

    The above is the detailed content of How to configure VS Code for Microsoft C++. For more information, please follow other related articles on the PHP Chinese website!

    Statement
    This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
    How to Use Roblox Quick Login on PC/Phone? Here Is a Full Guide! - MiniToolHow to Use Roblox Quick Login on PC/Phone? Here Is a Full Guide! - MiniToolApr 28, 2025 am 12:50 AM

    If you want to log in to your Roblox account on a new device without inputting the password, Roblox Quick Login can help you do that. This post from php.cn tells you how to use the Roblox quick login feature with full steps.

    PS5 vs Xbox Series vs PC: Which One Is Best for Hogwarts Legacy - MiniToolPS5 vs Xbox Series vs PC: Which One Is Best for Hogwarts Legacy - MiniToolApr 28, 2025 am 12:49 AM

    Hogwarts Legacy is out now on PS5, Xbox Series X/S, and PC. Which is best for Hogwarts Legacy? If you’re confused, don’t worry. In this post, php.cn provides a tutorial about Hogwarts Legacy PC vs PS5 vs Xbox Series X/S, and you can have a look.

    Download Realtek USB GbE Family Controller Drivers Windows 10/11 - MiniToolDownload Realtek USB GbE Family Controller Drivers Windows 10/11 - MiniToolApr 28, 2025 am 12:48 AM

    In this post, php.cn Software will show you some information about Realtek USB GbE Family Controller, including its definition, usage, and how to download the Realtek USB GbE Family Controller driver on your Windows 10/11 computer.

    Crucial T700 SSD Overview: It Has Record-Break Performance - MiniToolCrucial T700 SSD Overview: It Has Record-Break Performance - MiniToolApr 28, 2025 am 12:47 AM

    Crucial T700 PCIe Gen5 NVMe SSD has been released for a period. You can follow this post to learn the related information about this SSD that has record-break performance. In this post, we also introduce some php.cn software to help you manage the SS

    How to Download, Install, and Update RTX 4090 Drivers Win 10/11? - MiniToolHow to Download, Install, and Update RTX 4090 Drivers Win 10/11? - MiniToolApr 28, 2025 am 12:46 AM

    If you have a GeForce RTX 4090 Ti in hand, it is important to download and install the corresponding driver in time to make it work properly. If you are confused about how to do that, follow this guide on php.cn Website to get a detailed tutorial.

    Notion Dark Mode: How to Turn on and off on Desktop & Mobile - MiniToolNotion Dark Mode: How to Turn on and off on Desktop & Mobile - MiniToolApr 28, 2025 am 12:45 AM

    Most people think that it is more harmful to look at a screen in the dark. The sharp light easily makes your eyes damaged. Therefore, many people will pursue a dark mode to lower the damage. But is it really useful? Is the dark mode available on Noti

    How to Fix Valheim Stuck on Loading Screen? - MiniToolHow to Fix Valheim Stuck on Loading Screen? - MiniToolApr 28, 2025 am 12:44 AM

    If you are complaining of Valheim stuck on loading screen and don’t know what to do. This guide on php.cn Website will help you to find suitable solutions. Try the solutions mentioned below one by one until your issue is gone.

    Power Tactics to Disable and Clear Run History on WindowsPower Tactics to Disable and Clear Run History on WindowsApr 28, 2025 am 12:43 AM

    If you frequently use the Run window to directly open tools or documents, you will find the matching list gradually becomes longer and longer. Some people are searching for methods to clear Run history to make it look clean. This php.cn post might gi

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Tools

    SublimeText3 English version

    SublimeText3 English version

    Recommended: Win version, supports code prompts!

    ZendStudio 13.5.1 Mac

    ZendStudio 13.5.1 Mac

    Powerful PHP integrated development environment

    Safe Exam Browser

    Safe Exam Browser

    Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

    SublimeText3 Chinese version

    SublimeText3 Chinese version

    Chinese version, very easy to use

    EditPlus Chinese cracked version

    EditPlus Chinese cracked version

    Small size, syntax highlighting, does not support code prompt function