Aral Code

Getting Started Lesson 2 of 16

Getting Started with C — Compilers and Your First Program

Install a C compiler (GCC with Code::Blocks or MSYS2, or Clang on Mac), compile and run a program from the command line, and read compiler errors and warnings.

To run C code, you need a compiler. The most common free compilers are GCC and Clang. Here's how to get one and run your first program.

Option 1: An IDE with a built-in compiler (easiest on Windows)

  • Code::Blocks: download the installer whose name includes "mingw-setup". It includes GCC. Create a new "Console application" project, choose C, and press F9 to build and run.
  • Dev-C++ (Embarcadero version): small and simple, common in school computer labs.

Option 2: VS Code + a compiler

  • Windows: install MSYS2, then GCC with pacman -S mingw-w64-ucrt-x86_64-gcc, and add its bin folder to PATH.
  • Mac: run xcode-select --install in Terminal. This installs Clang (which also answers to gcc).
  • Linux: sudo apt install build-essential.

Then install VS Code's "C/C++" extension.

Compile and run from the command line

Save this as hello.c:

#include <stdio.h>

int main(void) {
    printf("Hello from C!\n");
    printf("Grade 12 - STEM\n");
    return 0;
}

Then, in the folder where you saved it:

gcc hello.c -o hello
./hello

Output

Hello from C!
Grade 12 - STEM
  • gcc hello.c compiles the file.
  • -o hello names the output program hello (hello.exe on Windows).
  • ./hello runs it. On Windows Command Prompt, type hello instead.

Turn on warnings

Add -Wall -Wextra to see helpful warnings about likely mistakes:

gcc -Wall -Wextra hello.c -o hello

Reading errors

#include <stdio.h>

int main(void) {
    printf("Hello\n")
    return 0;
}

Error

hello.c:4:22: error: expected ';' after expression
    printf("Hello\n")
                     ^
                     ;
1 error generated.

The message shows the file, line 4, column 22, and what's expected. Fix the first error first; one missing semicolon can cause several confusing errors below it.

Errors vs warnings

ErrorWarning
Program created?NoYes
MeaningThe code isn't valid CValid, but probably a mistake
ExampleMissing semicolonUsing a variable before giving it a value

No computer?

Search for an "online C compiler". Paste the code, press Run, and type any input in the "stdin" box. Everything in this course works there.

Quick Quiz

Check what you learned. Walang grade ito, practice lang. 🙂

1. What does -o hello do in gcc hello.c -o hello?
2. Which flag turns on most warnings in GCC?
3. A warning means…
4. Which compiler is installed on a Mac with xcode-select --install?

By Sir Reyel · Last updated 2026-12-04