Visual Studio Code (VS Code) is the most popular free editor for C programming in 2026. It gives you syntax highlighting, code completion (IntelliSense), one-click compile-and-run, and a visual debugger — all free and cross-platform. This guide sets it up for C from scratch on Windows, macOS, or Linux.
One thing to know up front: VS Code is not a compiler. It is an editor that drives a compiler you install separately (GCC). If you have not installed GCC yet, do that first:
If you just need to test a quick snippet, an online C compiler is faster than a full IDE setup. But for any real project, VS Code is worth the few minutes of configuration below.
Step 1 — Install VS Code
Download VS Code from the official site code.visualstudio.com and install it. It is free and open source, and runs on Windows, macOS, and Linux.
On Windows, during installation tick Add to PATH and Add “Open with Code” action — both make life easier later.
Step 2 — Verify GCC Is Installed
Open VS Code, then open its built-in terminal with Ctrl+` (backtick) — on macOS use Cmd+`. Type:
gcc --version
If you see a version number, you are ready. If you see command not found or not recognized, GCC is not on your PATH — go back to the install guide for your platform above.
Step 3 — Install the C/C++ Extension
- Click the Extensions icon in the left sidebar (or press Ctrl+Shift+X)
- Search for C/C++
- Install the one published by Microsoft (it has tens of millions of installs)
This extension adds IntelliSense (code completion), error squiggles, go-to-definition, and debugging support. Optionally, also install the C/C++ Extension Pack for a few extra tools, but the single C/C++ extension is enough to start.
Step 4 — Open a Folder and Create a File
VS Code works best when you open a folder, not a single file. Create a folder for your code (for example C:\code or ~/code), then in VS Code choose File → Open Folder and select it.
Create a new file called hello.c and type:
#include <stdio.h>
int main(void) {
printf("Hello from VS Code!\n");
return 0;
}
As you type, notice IntelliSense suggesting printf and showing its parameters — that is the C/C++ extension working.
Step 5 — Compile and Run with One Click
The simplest way to run your program:
- Open
hello.c
- Click the Run triangle (▷) in the top-right corner, or press F5 / Ctrl+F5
- When prompted, choose C/C++: gcc build and debug active file
VS Code compiles your file with GCC and runs it in the integrated terminal. The output appears at the bottom:
Hello from VS Code!
VS Code automatically creates a .vscode folder with tasks.json (build settings) and launch.json (debug settings) the first time. You normally never need to touch these.
Step 6 — Use the Debugger
This is where VS Code beats the command line. Click in the gutter to the left of any line number to set a breakpoint (a red dot), then press F5. Execution pauses at that line and you can:
- Inspect variable values in the left panel
- Step through code line by line with F10 (step over) and F11 (step into)
- Watch how loops and pointers change in real time
For learning C — especially pointers and arrays — stepping through with a debugger teaches more than any printf ever will.
Recommended Settings for C Beginners
Open tasks.json (inside the .vscode folder) and add these flags to the args array so every build catches more bugs:
"-Wall",
"-Wextra",
"-std=c17",
"-g",
| Flag |
Why |
-Wall -Wextra |
Turn on warnings — they catch real bugs early |
-std=c17 |
Use a modern, well-defined C standard |
-g |
Add debug info so breakpoints work |
VS Code vs a Standalone IDE
VS Code needs a little setup (install GCC, install the extension, first-run config). If you want something that works the instant you install it — compiler already bundled, no PATH configuration — a standalone IDE may suit you better as a complete beginner. See our guide to Code::Blocks, which includes its own compiler and runs out of the box.
For a broader comparison of every option, see Best Free C IDEs for Beginners in 2026.
Common Issues
| Problem |
Fix |
| “gcc not found” when you press F5 |
GCC is not on PATH — verify with gcc --version in the terminal, reinstall if needed |
| IntelliSense red squiggles everywhere but it compiles fine |
Run C/C++: Select IntelliSense Configuration from the Command Palette and pick your compiler |
| No “gcc build and debug” option appears |
Make sure the C/C++ extension by Microsoft is installed and enabled |
| Program window closes instantly |
Run with Ctrl+F5 (Run Without Debugging) to keep the terminal open |
What’s Next
Your environment is fully set up. Time to write real programs — browse our full list of C programs with examples, from beginner exercises to sorting algorithms and data structures. Set a breakpoint inside one of the sorting programs and watch the array change step by step — it is the fastest way to understand how they work.
As an Amazon Associate we earn from qualifying purchases.
Recommended Book
With VS Code set up, the best book to actually learn the language is The C Programming Language by Brian Kernighan and Dennis Ritchie (K&R). Type its examples into VS Code and step through them with the debugger to see exactly how each one works.