C Demo Examples
Practice programs, one file each. Every demo is self-contained, commented, and free of unsafe legacy functions. Compile any of them with the safe recipe:
gcc -std=c11 -Wall -Wextra -Werror file.c -o app, then run ./app (Windows: ./app.exe).
How to use: click View to open a file in the code viewer, read its comments, download it, compile it with the flags above, then modify it on purpose. The demos are ordered by lesson — start at 01 and work up.
Foundations
Syntax, variables, operators, control flow, loops, and functions from PHASE 1 and 2.
| # | Description | Link |
|---|---|---|
| 1 | Hello, World | View |
| 2 | Variables & Types | View |
| 3 | Operators & Expressions | View |
| 4 | Control Flow | View |
| 5 | Loops | View |
| 6 | Functions & Recursion | View |
Memory & Pointers
Pointers, strings, and heap management from PHASE 3.
| # | Description | Link |
|---|---|---|
| 7 | Pointers & Dereferencing | View |
| 8 | Strings & the NUL Terminator | View |
| 9 | Dynamic Memory | View |
| 10 | Structs & Unions | View |
Data Structures & Algorithms
Collections and the classic algorithms from PHASE 4.
| # | Description | Link |
|---|---|---|
| 11 | Linked List | View |
| 12 | Dynamic Array (Vector) | View |
| 13 | Hash Table | View |
| 14 | Binary Search | View |
| 15 | Sorting: qsort & Quicksort | View |
| 16 | Recursion & Memoization | View |
| 17 | Sieve of Eratosthenes | View |
Advanced & Systems
Callbacks, bit manipulation, and files from PHASE 5.
| # | Description | Link |
|---|---|---|
| 18 | Function Pointers & Callbacks | View |
| 19 | Bit Flags & Masks | View |
| 20 | File I/O & errno | View |
Practice move: after running each demo, break it: change a
%d to %s, drop a free, or index past the end — then recompile with -fsanitize=address,undefined and watch the sanitizer name the exact bug.