Skip to main content

Visual Studio Code for C Programming

2 min read Updated May 29, 2025
Share:
On this page (10sections)

Introduction

Visual Studio Code (VS Code) is a popular free editor for C programming. Combined with MSYS2 GCC and the C/C++ extension, it provides syntax highlighting, IntelliSense, debugging and integrated terminal support.

Step 1 — Install VS Code

Download from the official site: https://code.visualstudio.com/

Step 2 — Install a C Compiler

VS Code does not include a compiler. On Windows, install GCC via MSYS2:

  1. Download MSYS2 from https://www.msys2.org/
  2. Open MSYS2 UCRT64 terminal
  3. Run: pacman -S mingw-w64-ucrt-x86_64-gcc
  4. Add C:\msys64\ucrt64\bin to your Windows PATH

Full steps: GCC C Compiler guide

Verify in a new terminal: gcc --version

Step 3 — Install the C/C++ Extension

  1. Open VS Code
  2. Go to Extensions (Ctrl+Shift+X)
  3. Search for C/C++ by Microsoft
  4. Click Install

Extension page: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

Step 4 — Create and Run a C Program

  1. Create a folder for your project
  2. Create hello.c:
#include <stdio.h>

int main(void) {
    printf("Hello from VS Code!\n");
    return 0;
}
  1. Open the folder in VS Code (File → Open Folder)
  2. Open the integrated terminal (Ctrl+`` )
  3. Compile and run:
gcc hello.c -o hello
./hello

On Windows: hello.exe instead of ./hello

Optional — Debugging

Install the C/C++ Extension debug support, then create a .vscode/launch.json for GDB debugging. Microsoft provides a full walkthrough: Using GCC with MinGW in VS Code

VS Code vs Traditional IDEs

FeatureVS CodeCode::Blocks / Geany
SetupEditor + separate compilerOften bundled compiler
Best forModern workflow, Git, extensionsBeginners, single installer
DebuggingVia GDB extension configBuilt-in

Frequently Asked Questions

Do I need Visual Studio to use VS Code for C?
No. VS Code is a lightweight editor. Install a separate compiler (MSYS2 GCC on Windows) and the Microsoft C/C++ extension.
Is VS Code free?
Yes. Visual Studio Code is free and open source from Microsoft.

Related Tutorials

Search tutorials