C tutorial
Learn memory, pointers, and efficient systems programming.
Course contents
Programming fundamentals
C Variables
Declare typed values.
C Arrays
Store a fixed sequence.
C Pointers
Work with memory addresses.
C conditions, loops, and totals
Combine a counted loop with an even-number condition.
C strings and null terminators
Traverse characters without reading beyond the string.
C functions and pointer parameters
Modify caller-owned values through valid addresses.
C structures and records
Group related fields into a typed record.
C dynamic memory and ownership
Allocate, check, use, and free a heap buffer.
C reading and writing text files
Write lines to a file with fprintf, read them back with fgets, and parse each line with sscanf.
C bit manipulation and flags
Set, clear, test, and toggle bits with &, |, ^, ~, and shifts, and count set bits.
C two-dimensional arrays
Store a matrix, transpose it, and multiply it with another one.
C macros versus inline functions
See how a macro evaluates its arguments more than once and why a function is safer.
Data structures and algorithms
C array search with explicit length
Search only within the supplied array bounds.
C linked nodes and traversal
Connect records with pointers and follow a chain.
C array-based stacks and circular queues
Build a fixed-capacity stack and a queue that wraps around the end of its array.
C binary search and the standard bsearch
Find a value in a sorted array in logarithmic time, by hand and with the library function.
C sorting: bubble sort versus quicksort
Implement two sorts, count their comparisons, and see why O(n log n) beats O(n²).
C binary search trees with malloc and free
Allocate tree nodes dynamically, traverse them in order, and release every node.
C string algorithms
Write strlen and strcmp by hand, check palindromes, and count occurrences with strstr.
C dynamic programming: longest common subsequence
Fill a table of subproblem answers to find the longest sequence that two strings share.
Analysis of algorithms
Database systems
Operating systems
Computer networks
Software engineering
Information security
C: preventing buffer overflows with snprintf
Copy text into a fixed buffer without writing past its end, and detect truncation.
C: validating numeric input with strtol
Accept only text that is entirely a number in the allowed range, and reject everything else.
C: why a one-time pad key must never be reused
XOR two messages with the same key and show that the key cancels out and leaks information.