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 itsbinfolder to PATH. - Mac: run
xcode-select --installin Terminal. This installs Clang (which also answers togcc). - 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.ccompiles the file.-o hellonames the output programhello(hello.exeon Windows)../helloruns it. On Windows Command Prompt, typehelloinstead.
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
| Error | Warning | |
|---|---|---|
| Program created? | No | Yes |
| Meaning | The code isn't valid C | Valid, but probably a mistake |
| Example | Missing semicolon | Using 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. 🙂
By Sir Reyel · Last updated 2026-12-04