How to write C in Visual Studio Code?

MahajanAditi18
3 min readJun 21, 2021

--

Microsoft Visual Studio Code is an integrated development environment (IDE) from Microsoft. It is used to develop computer programs, as well as websites, web apps, web services and mobile apps.

Visual Studio includes a code editor supporting IntelliSense (the code completion component) as well as code refactoring.

Download & Install the C/C++ Extension

  • We need to click on the extension button that displays a sidebar for downloading and installing the C/C++ extension in the visual studio code. In the sidebar, type C Extension.
  • After that, click on the C/C++

In this image, click on the Install button to install the C/C++ extension.

  • After clicking the Install button, it shows the below image.

In this image, we can see it shows the Uninstall button that means the C/C++ extension has been successfully downloaded in the visual studio code.

Download & Install Compiler Extension

A MinGW is an advanced GCC compiler software used to compile and execute code. It is software that supports only the window operating system.

Download the MinGW-w64 Compiler

  1. Install Mingw-w64 via the SourceForge website. Click https://nuwen.net/mingw.html to download the Windows Mingw-w64 installer.
  2. After that, click on the Download button, then it starts the downloading of the MinGW GCC compiler.
  3. MinGW software has been successfully downloaded into the system.
  4. Now we double-click on the MinGW set up to install the compiler.
  5. Click on the Install.
  6. After clicking the continue button, it shows step 2 of MinGW Installation Manager.
  7. Finally MinGW is installed.

Set the Environment Path for the MinGW Set Up

After downloading and installing the MinGW compiler, we now set the environment path to include the C/C++ compiler directory.

  1. Go to the installation directory of the MinGW Set Up. Here we installed the setup at the C drive.
  2. Double click on the MinGW folder.
  3. After that, click on the bin folder and then copy the directory path. Here is the path of the MinGW folder path: C:\MinGW\bin
  4. After copying the directory path, go to This PC -> Right Click on This PC -> Select/ Click on the Properties.
  5. Click on the Environment Variables to set the directory path.First, we have to click on the System Variables Path and then click on the Edit button.
  6. As we click on the Edit button, it shows a popup window to set a new path.
  7. we click on the New button and then paste the C:\MinGW\bin path; after that, click the OK button.
  8. Similarly, click the OK button to the Environment Variables and System Properties.
  9. If we want to check that the MinGW has been successfully installed in the system: go to the Command Prompt or cmd, write the gcc -version, and press the Enter.

Start Coding in the Visual Studio Code Editor!

  • Here we created a C Program folder to store all program code. We can create a folder with any name in any directory.
  • Go to the VS Code and click on the Add Folder.
  • As we click on the Add Folder, it shows a popup dialog box to select the folder to store the program.
  • After selecting the folder, click on the Add The selected folder appears in the explorer section.
  • Move the mouse over the C PROGRAM folder, it shows a + Click on the button and write the file name as ‘ xyz.c’.
  • Now write the code in C/C++
  • And hen we click on the Run button or press the Ctrl + Alt + N, it displays the below output.

Now write and understand simple C programming in the VS Code editor.

Thank you…

Hope this content was useful …

--

--