Setting Up VS code for C Programming in Windows
Published: 2022-11-14 11:02:54

Vs code is a powerful source code editor which is developed by Microsoft for windows, MacOs and Linux. It has a lot of functionality that eases the editing, building and debugging process which helps a programmer being more productive. If you're a beginner programmer and you've chosen the VS code editor as your primary code editor and wanted to run C programs, you must have faced some difficulties while running the C code.

In this guide, I'll be showing step by step process which you can follow to setup VS code for C programming:
####Prerequisites:
* You should have VS code installed on your system If you haven't installed VS code, install it from [here.](https://code.visualstudio.com/download)
* You should download MinGw which provide C, C++ compilers and other related tools. Download **mingw-18.0-without-git.exe** which is an installer for MinGw by clicking [here.](https://nuwen.net/mingw.html)

After you've all the prerequisites ready, proceed to the following steps:
###Step 1:
* Run MinGw installer which will extract the folder named MinGw in your provided location. I suggest you to extract it in **C:\ drive.**
![MinGw Folder](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7gsq3zvlkp8cu1m1gv8x.png)
* Open MinGw folder and go to bin folder and copy the directory path from the address bar
![Address Bar](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nre54rtyljakvx3z8ubo.png)

###Step 2:###
* Now, We have to provide the path to our Compiler in System Environment Variable. Search **environment** in windows search bar.
![Environment Variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l9ko3zgp1sd2hrnobbj8.png)
* A dialog box will open up. Then, Click ***Advanced > Environment Variables...***
![Advanced Environment Variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9pbcc0uk3cvbztdj3pay.png)
* Another dialog box will open up. Click **Path > Edit...**
![Edit Environment Variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5ovwpuw3i7urwiccvem.png)
* You'll see the edit environment variable dialog box. Now, Click New and Paste the copied address.
![New Environment Variable](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q5ebcb0uri2jr1zp34tb.png)
* Next, Click **OK** to close all the dialog boxes.
* If you want to check if MinGw is properly installed or not, Open Command Prompt and type **gcc --version** and Press Enter.
![GCC](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/upw3ooorv5ao0f4qjx7r.png)

###Step 3:
* Up next, We have to install some extensions for VS code. Open VS Code and Click on **Extensions.**
![Extensions](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/whouysxhqkz7psykajrl.png)
*  Search for **C/C++ Intellisense MS** in the search bar and install it
. Also, Search for **Code Runner** and install it too.
![C/C++ Intellisense MS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fg12a4pimpizkwgzaiiu.png)
![Code Runner](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/exng5jk1yy39u3okio1o.png)
* Let's write a program to calculate sum of two numbers and try to
run it.
![Run Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ajgi555c3n9f856un5q.png)

###Step 4:
* When you run the program it shows **[Running]** in the output but doesn't prompt for the user input as seen below:
![Running](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9t1ny2j6v6l37p8w2tc.png)
* Above situation is due to the output tab being read only. So, we cannot take any input from the user.
* First of all, stop all background running C program by pressing **CTRL + ALT + M** from keyboard
* Next, Click on **File > Preferences > Settings** which will open the Settings tab
![Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wzjpxv4xdby8jwcvzmdr.png)
* Now, Click on **>Extensions**
![Settings](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8of4jyqv40ms8rl19x72.png)
* Scroll down and click on **Run Code Configuration**
![Run Code Config](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfc5i7pnaxwrynhd2pqg.png)
* Now, Scroll the right-side pane and Tick on **Run In Terminal**
![Run In Terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0cptcybgitlklel1y40r.png)
* Close the settings tab.
* Run the Code.
![Code Is Running](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r4j83tyd9t3wc9meh366.png)
* **Hooray!!** Our code is running successfully.

Do Comment if you're facing any problem. I'll try to help you according to my knowledge😊 .