Series 4: Advanced C

With pointers and memory under your belt, you're ready for C's advanced features: structs, file I/O, function pointers, void pointers, and linked lists. This is where C starts to feel powerful — you'll build generic data structures from scratch.

Lessons

4.1: How Do I Define and Use Structs and Unions?

~22 min · Week 8 · Prereq: Lessons 3.1, 2.12

struct, typedef, unions. C’s version of Java classes — data without methods.


4.2: How Do I Use Pointers to Access Struct Members?

~20 min · Week 8 · Prereq: Lessons 4.1, 3.2

The -> operator, passing structs by pointer, arrays of structs on the heap.


4.3: How Do I Read and Write Files in C?

~22 min · Week 8 · Prereq: Lessons 2.5, 4.1

fopen, fclose, fprintf, fscanf, fgets. Error checking (always check return values!). Compared to Java’s Scanner and PrintWriter.


4.4: How Do I Sort Structs by Different Keys?

~18 min · Week 8 · Prereq: Lessons 4.1, 2.14

Selection sort on struct arrays, sorting by different fields, comparison functions. Preparation for function pointers.


4.5: How Do I Organize Multi-File C Projects?

~20 min · Week 8 · Prereq: Lessons 2.11, 4.1

Separating interface (.h) from implementation (.c), static functions, advanced Makefile patterns.


4.6: What Are Function Pointers and How Do I Use Them?

~22 min · Week 9 · Prereq: Lessons 2.9, 3.1

Storing and calling functions by pointer. C’s version of Java interfaces and callbacks.


4.7: How Do Void Pointers Enable Generic Programming?

~20 min · Week 9 · Prereq: Lessons 4.6, 3.3

void * as the universal pointer. Type erasure, casting, and why qsort works on any type.


4.8: How Do I Build Generic Data Structures with Pointers and Functions?

~22 min · Week 9 · Prereq: Lessons 4.6, 4.7, 3.7

Linked lists with void pointers and function pointers. Building Java-like generics by hand in C.


4.9: How Do Lab 8 Project and Generic Programming Fit Together?

~18 min · Week 9 · Prereq: Lessons 4.6–4.8

Capstone synthesis: applying generic programming patterns to the Lab 8 project.


Related resources:

Previous series: ← Series 3: Pointers & Memory

Next series: Series 5: Systems Programming →