Set up your computer
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
Run C on your own computer
- This playground is great for learning — your code is built and run for you.
- For your own projects, it helps to set C up on your computer.
- It takes about 15 minutes, and you only do it once.
Step 1 — Install a compiler
- A compiler turns your C code into a program the computer can run.
- Windows: install MSYS2 from msys2.org — it gives you
gcc. - macOS: open Terminal and run the command below to get
clang. - Linux: install
build-essential, which includesgcc.
xcode-select --install
Step 2 — Install VS Code
- VS Code (Visual Studio Code) is a free, popular code editor from Microsoft.
- Get it from code.visualstudio.com and install it.
- This is where you will write your code.
Step 3 — Add the C/C++ extension
- Open VS Code and click the Extensions icon on the left.
- Search for C/C++ (the one by Microsoft) and click Install.
- It adds colours, error hints, and a debugger for C.
Step 4 — Check the compiler works
- Open a terminal (in VS Code: Terminal → New Terminal) and type:
gcc --version
- You should see a version line. If you do, your compiler is ready.
Step 5 — Compile and run your first file
- Make a new file called
hello.cand type this in:
#include <stdio.h>
int main(void) {
printf("Hello from my own computer!\n");
return 0;
}
- In the terminal, build it and then run it:
gcc hello.c -o hello
./hello
- You just compiled and ran C outside the browser.