How to Set Up VS Code for C and C++ Programming on Windows (Step-by-Step Guide)

Table of contents
- How to Set Up VS Code for C and C++ Programming on Windows (Step-by-Step Guide)
- π Step 1: Download and Install VS Code
- βοΈ Step 2: Download and Install MinGW (GCC Compiler)
- π οΈ Step 3: Setup Environment Variables
- π§© Step 4: Install C/C++ Extension in VS Code
- π» Step 5: Write Your First C Program
- π Step 6: Compile and Run
- β‘ Bonus Tip: tasks.json for Easier Compilation
- π― Conclusion
How to Set Up VS Code for C and C++ Programming on Windows (Step-by-Step Guide)
Want to start coding in C or C++ using Visual Studio Code (VS Code)?
Youβre in the right place. In this step-by-step guide, Iβll show you how to set up VS Code with MinGW (GCC Compiler) to write, compile, and run your C/C++ programs easily.
Perfect for:
Beginners
College students (BCA, B.Tech, Diploma)
Anyone who wants a lightweight coding setup
π Step 1: Download and Install VS Code
Install it on your system like any normal app.
βοΈ Step 2: Download and Install MinGW (GCC Compiler)
During installation, make sure you select:
mingw32-gcc-g++
mingw32-gcc-gcc
Install it to
C:\MinGW
π οΈ Step 3: Setup Environment Variables
Control Panel β System β Advanced System Settings β Environment Variables
Find Path β Click Edit
Add this path:
C:\MinGW\bin
π§© Step 4: Install C/C++ Extension in VS Code
Open VS Code
Go to Extensions (Ctrl+Shift+X)
Search and install C/C++ by Microsoft
π» Step 5: Write Your First C Program
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
π Step 6: Compile and Run
Open Terminal (Ctrl+`)
Compile the program:
gcc filename.c -o output.exe
- Run the program:
./output.exe
β‘ Bonus Tip: tasks.json for Easier Compilation
{
"version": "2.0.0",
"tasks": [
{
"label": "build and run",
"type": "shell",
"command": "gcc",
"args": ["${file}", "-o", "${fileDirname}\\${fileBasenameNoExtension}.exe", "&&", "${fileDirname}\\${fileBasenameNoExtension}.exe"],
"problemMatcher": ["$gcc"]
}
]
}
Now just press Ctrl+Shift+B to compile and run automatically.
π― Conclusion
Now youβre fully set to code, compile, and run C/C++ programs on Windows using VS Code. π₯
Need help? Drop a comment here or check my YouTube channel for the video version of this tutorial.
π More Coming Soon:
C Programming Masterclass Playlist (2025 Edition) β Subscribe on YouTube for updates
C Projects for Beginners
C to C++ Full Roadmap
π Connect with Me:
- π All My Links: https://codewithmishu.vercel.app/
Subscribe to my newsletter
Read articles from Munish Kumar Sharma directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Munish Kumar Sharma
Munish Kumar Sharma
π Yo! Iβm Munish β a full stack web dev + AI/ML learner building in public. π» On this channel: Beginner-friendly web development tutorials Dev vlogs + learning journey AI/ML experiments coming soon π― Subscribe to grow with me and build cool stuff, one line of code at a time. #CodeWithMishu | Learn. Build. Dominate.