π§° What You Need to Install:
-
β A code editor (like VS Code)
-
β A C/C++ compiler (like MinGW or GCC)
-
β C/C++ extensions for your editor
πͺ Step-by-Step: Install C/C++ on Windows (VS Code + MinGW)
β Step 1: Install VS Code
-
Download from π https://code.visualstudio.com
-
Install it with default settings (check βAdd to PATHβ).
β Step 2: Install MinGW Compiler
-
Go to π https://www.mingw-w64.org or download directly from:
π https://sourceforge.net/projects/mingw-w64/ -
Run the installer:
-
Version:
x86_64
-
Threads:
posix
-
Exception:
seh
-
Build revision: any is fine
-
Install to a folder like:
C:\mingw-w64
-
-
After install, add it to System PATH:
-
Go to Start > Environment Variables
-
Under System Variables, find
Path
β Edit -
Add:
C:\mingw-w64\bin
(your exact path may vary)
-
-
To test if it works:
-
Open Command Prompt
-
Type:
-
You should see a version number (like
g++ (GCC) 13.x.x
)
-
β Step 3: Install C/C++ Extension in VS Code
-
Open VS Code
-
Press
Ctrl+Shift+X
to open Extensions -
Search for:
π “C/C++” by Microsoft -
Click Install
β Step 4: Write and Run C or C++ Code
-
Create a new folder and open it in VS Code
-
Create a new file like
main.cpp
ormain.c
-
Paste sample code:
Example for C:
Example for C++:
β Step 5: Compile and Run Your Code
-
Open Terminal in VS Code (
Ctrl + ~
) -
Type:
or (for C):
π You should see:
or
π§ For Linux Users
-
Open Terminal
-
Install compiler:
-
Then compile:
π For macOS Users
-
Open Terminal
-
Install Xcode tools:
-
Compile and run like on Linux.
π§ Summary
Tool | Purpose |
---|---|
VS Code | Code writing/editor |
MinGW | Compiler for C/C++ |
g++/gcc | Build and run code |
C/C++ ext | Syntax, IntelliSense |