How to Set up Visual Studio Code for C and C++ Programming

Before Setting up Visual Studio Code for C and C++ Programming yo first need to install Mingw 64 on your pc. To install you can check this article.

Now I will also tell you how to use the GCC compiler with vs code because many people asking that How to Set up Visual Studio Code for C and C++ Programming.

Now I am going to show you how to install and set up visual studio code in your windows 10 operating system 

and then I will also show you how to set up your visual studio code for c and c++ programming languages

How to install visual studio code

To use GCC compiler for c and c++ first you need to install vs code for your pc. Here are the steps to install visual studio code.

  • So let’s begin now to install visual studio in  your windows 10 operating system first you need to download it by clicking here
  • Now after downloading Visual Studio Code, Just double click on it to install
  • After accepting the license agreement, click on next and choose your installation directory. I again recommended keeping it default.
  • Click on next.
  • Now in this step, Check all the options as shown in the below screenshot (important). Now click on next and tap on install.

After installation has finished click on the finish.

Now open the vs code because you need to add extensions in VS code which will help you to run the c or c++ code more efficiently.

  1. These two extensions are
  2. C/C++
  3. Code Runner

To download these extensions just open Visual Studio Code and click on the icon shown below

set up Visual Studio Code for C and C++ Programming
  • And search c/++ and install the extension by simply clicking on the install button
  • The next extension we are going to install is code runner. 

To download this extension search code runner as you search before and click on that install option and wait for the installation to finish

After installing both extensions restart your Visual studio code.

Here is one important thing

After installing the code runner extension, The problem is in your program is that if you have to take input from the user then from this output tab we can’t really provide the input that’s because this output tab is read-only. So we need to have a solution for this one.

To solve this error

  1. At first click on the file showing at least the top corner.
How to Set up Visual Studio Code for C and C++ Programming

2. And you have to go to preferences and Here select settings

How to Set up Visual Studio Code for C and C++ Programming

3. And here you need to click on extensions And Now if you scroll down then you guys can see run code configuration click on that,

How to Set up Visual Studio Code for C and C++ Programming

And again scroll down and here you need to check the run in the terminal.

  • and after that press Ctrl+S to save it and
  • close the settings

Writing and running the first program

Now as we Set up Visual Studio Code for C and C++ Programming, So now to check that your Gcc and visual code are working we need to check it by running a simple C program.

For that open any folder on your pc. Now, right-click and open visual studio code.

To run your first program create a file like a demo.cc as shown.

How to Set up Visual Studio Code for C and C++ Programming

And Write a simple c program as 

# include<stdio.h>

int main(){

    printf(“Hello world”);

    return 0;

}

NOW save it by pressing Ctrl+s and click on the run button,

How to Set up Visual Studio Code for C and C++ Programming

If your program run successfully, congrats successfully  Set up Visual Studio Code for C and C++ Programming languages.

But if it’s showing some error message us on Instagram or comment down we will try our best to solve your problem. If this article about How to Set up Visual Studio Code for C and C++ Programming is helpful to you, share it with your friends.

Check our other articles

Leave a Comment