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.

#DescriptionLink
1Hello, WorldView
2Variables & TypesView
3Operators & ExpressionsView
4Control FlowView
5LoopsView
6Functions & RecursionView

Memory & Pointers

Pointers, strings, and heap management from PHASE 3.

#DescriptionLink
7Pointers & DereferencingView
8Strings & the NUL TerminatorView
9Dynamic MemoryView
10Structs & UnionsView

Data Structures & Algorithms

Collections and the classic algorithms from PHASE 4.

#DescriptionLink
11Linked ListView
12Dynamic Array (Vector)View
13Hash TableView
14Binary SearchView
15Sorting: qsort & QuicksortView
16Recursion & MemoizationView
17Sieve of EratosthenesView

Advanced & Systems

Callbacks, bit manipulation, and files from PHASE 5.

#DescriptionLink
18Function Pointers & CallbacksView
19Bit Flags & MasksView
20File I/O & errnoView
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.