Developing in C on Windows is a breeze with the right tools. This guide will help you choose and set up your preferred environment, ensuring you have everything you need to write, compile, and debug your C code.
We will cover two primary approaches:
MinGW-w64 with Visual Studio Code: Ideal for a lightweight, customizable setup with a powerful text editor. This is often preferred by those who want to be closer to the command line or are familiar with VS Code for other languages.
Microsoft Visual Studio Community: A comprehensive, feature-rich IDE from Microsoft, excellent for larger projects, Windows-specific development, and those who prefer an all-in-one graphical interface.
This combination provides a modern, efficient, and free development environment.
MinGW-w64 provides the GCC compiler toolchain for Windows, allowing you to compile C code.
Download MinGW-w64:
Go to the official MinGW-w64 SourceForge page: https://sourceforge.net/projects/mingw-w64/files/
Look for the latest stable release. As of June 2025, look for a recent build under the "MinGW-W64 GCC-8.1.0" (or newer) or "MinGW-W64 GCC-11.2.0" (or newer) sections. Specifically, You will want a x86_64-posix-seh
or x86_64-w64-mingw32
archive.
Recommendation: Download the file that looks something like x86_64-*-posix-seh.zip
(e.g., mingw-w64-x86_64-13.1.0-posix-seh-r0.zip
if available). "x86_64" is for 64-bit systems, "posix" is for POSIX threads (better compatibility), and "seh" is a common exception handling model.
Extract MinGW-w64:
Create a new folder directly in your C drive, for example, C:\MinGW
. Avoid spaces in the path.
Extract the contents of the downloaded .zip
file directly into this C:\MinGW
folder. You should see a mingw64
folder inside C:\MinGW
(i.e., C:\MinGW\mingw64
).
Add MinGW-w64 to System PATH:
This step allows you to run GCC commands from any directory in your command prompt or VS Code terminal.
Press Windows Key + R
, type sysdm.cpl
, and press Enter to open System Properties.
Go to the Advanced
tab and click Environment Variables...
.
Under "System variables" (or "User variables" if you only want it for your user account), find and select the Path
variable, then click Edit...
.
Click New
and add the path to the bin
folder within your MinGW-w64 installation. For example: C:\MinGW\mingw64\bin
Click OK
on all open windows to save the changes.
Verify Installation:
Open a new Command Prompt (cmd
) or PowerShell window.
Type gcc --version
and press Enter. You should see information about the GCC compiler, confirming It is installed and accessible.
Type gdb --version
to confirm the debugger is also installed.
VS Code is a popular, lightweight, and highly customizable code editor with excellent C/C++ support via extensions.
Download VS Code:
Go to the official VS Code website: https://code.visualstudio.com/
Download the "User Installer" for Windows (x64 recommended).
Install VS Code:
Run the downloaded installer.
Accept the license agreement.
During installation, check the boxes for "Add 'Open with Code' action to Windows Explorer file context menu" and "Add 'Open with Code' action to Windows Explorer directory context menu" for convenience.
Click "Next" and "Install" to complete the setup.
This extension provides IntelliSense, debugging, and code Browse for C/C++.
Open VS Code.
Go to the Extensions view by clicking the square icon on the left sidebar or pressing Ctrl+Shift+X
.
Search for "C/C++" and install the extension published by Microsoft.
You will need to create a simple configuration to tell VS Code how to build and debug your C programs using MinGW-w64.
Create a New Folder for your C Project:
Create a folder anywhere on your computer (e.g., C:\Users\YourUser\Documents\C_Projects\HelloWorld
).
Open this folder in VS Code (File > Open Folder...
).
Create a Sample C File:
Inside your project folder in VS Code, create a new file named hello.c
.
Add the following simple C code:
#include <stdio.h>
int main() {
printf("Hello, how2lab.com!\n");
return 0;
}
Configure Build Task:
In VS Code, go to Terminal > Configure Default Build Task...
.
Select C/C++: gcc.exe build active file
. This will create a tasks.json
file inside a .vscode
folder in your project. This file tells VS Code how to compile your hello.c
file.
Run the Program:
With hello.c
open, press Ctrl+Shift+B
(or Terminal > Run Build Task
). This will compile your code. You should see output in the integrated terminal confirming successful compilation.
After compilation, an executable file (e.g., hello.exe
) will be created in your project folder.
In the VS Code terminal, type .\hello.exe
and press Enter to run your program. You should see "Hello, how2lab.com!" printed.
Git is essential for managing your code, tracking changes, and collaborating with others.
Download Git for Windows:
Go to the official Git website: https://git-scm.com/download/win
Download the latest installer.
Install Git:
Run the installer. The default options are generally good for most users. You can choose your preferred default text editor during the setup.
Ensure "Git Bash Here" and "Git GUI Here" are enabled in the context menu options for easy access from File Explorer.
Verify Installation:
Open a new Command Prompt or Git Bash.
Type git --version
and press Enter to confirm Git is installed.
VS Code has excellent integrated Git support once Git is installed on your system.
Visual Studio Community is a powerful, free IDE for individuals, open-source projects, and academic use. It comes with Microsoft's own C/C++ compiler (MSVC).
Go to the Visual Studio Download Page:
Click "Free download" for the Visual Studio Community edition.
Run the Installer:
Execute the downloaded vs_community__*.exe
file.
The Visual Studio Installer will launch.
Select Workloads:
In the "Workloads" tab, select "Desktop development with C++". This is the core workload for C and C++ development on Windows.
On the right side, in the "Installation details" pane, you can review and optionally add components. For standard C development, the default components are usually sufficient.
Click the "Install" button. The installation might take a significant amount of time and disk space (several GBs), depending on selected components.
Launch Visual Studio:
Once installed, search for "Visual Studio 2022" (or the latest version) in your Start Menu and open it.
You might be prompted to sign in with a Microsoft account (optional for Community edition, but recommended for full features).
Create a New Project:
On the startup screen, select "Create a new project".
In the "Create a new project" dialog:
Filter by Language: C++ (C projects are handled within the C++ environment in Visual Studio).
Search for "Empty Project" and select the one with "C++" and "Windows" tags. Click Next
.
Give your project a Name (e.g., HelloWorldC
), choose a Location, and optionally a Solution name. Click Create
.
Add a Source File:
In the Solution Explorer (usually on the right), right-click on your project name (e.g., HelloWorldC
).
Go to Add > New Item...
.
Select "C++ File (.cpp)" but make sure to change the file name extension to .c
(e.g., main.c
). Click Add
.
Write Your C Code:
In main.c
, add the following simple C code:
#include <stdio.h>
int main() {
printf("Hello from Visual Studio!\n");
return 0;
}
Compile and Run:
Go to Build > Build Solution
(or press Ctrl+Shift+B
). This compiles your code.
Go to Debug > Start Without Debugging
(or press Ctrl+F5
). A console window will open, display "Hello from Visual Studio!", and then prompt you to press a key to close.
Visual Studio has built-in Git integration. If you didn't install Git separately (as in Option 1, Step 5), you can add it via the Visual Studio Installer.
Open the Visual Studio Installer (search for it in the Start Menu).
Click Modify
next to your installed Visual Studio version.
Under "Individual components," search for "Git for Windows" and check the box.
Click Modify
to install it.
Pros: Lightweight, fast, highly customizable, great for command-line familiarity, excellent cross-platform feel. Good for general C development and learning.
Cons: Requires manual configuration of paths and build tasks (though the C/C++ extension helps automate this). Debugging setup can be slightly more involved initially.
Pros: All-in-one powerful IDE, excellent integrated debugger, rich features for large projects, seamless Windows-specific development (e.g., GUI applications with WinAPI/MFC).
Cons: Large installation size, can feel overwhelming for absolute beginners due to its vast features. Primarily focused on Windows.
No matter which path you choose, You will have a robust C development environment ready to tackle everything from basic algorithms to complex socket programming. Happy coding!
How to move your Email accounts from one hosting provider to another without losing any mails?
How to resolve the issue of receiving same email message multiple times when using Outlook?
Self Referential Data Structure in C - create a singly linked list
Mosquito Demystified - interesting facts about mosquitoes
Elements of the C Language - Identifiers, Keywords, Data types and Data objects
How to pass Structure as a parameter to a function in C?
Rajeev Kumar is the primary author of How2Lab. He is a B.Tech. from IIT Kanpur with several years of experience in IT education and Software development. He has taught a wide spectrum of people including fresh young talents, students of premier engineering colleges & management institutes, and IT professionals.
Rajeev has founded Computer Solutions & Web Services Worldwide. He has hands-on experience of building variety of websites and business applications, that include - SaaS based erp & e-commerce systems, and cloud deployed operations management software for health-care, manufacturing and other industries.