C function pointers and callbacks: behaviour as data
12 steps · about 3 h 25 min · Intermediate
- Callback Function in C (article, TutorialsPoint, 15 min)
It starts with the core idea that a function has an address, which a pointer can store and call.
- Function Pointers (video, YouTube, 15 min)
A worked demo of declaring and calling function pointers, plus callback use cases, reinforces the reading.
- Function Pointer in C - Sanfoundry (article, Sanfoundry, 15 min)
It covers declaration, assignment, callbacks as arguments and arrays of function pointers in one place.
- Callbacks in C - GeeksforGeeks (article, GeeksforGeeks, 15 min)
It lays out the three steps of a callback: define it, declare the pointer, then invoke it.
- Function Pointers and Callbacks in C - An Odyssey (article, Open Source For You, 20 min)
It shows how to register a callback for events and warns about the parenthesis trap in declarations.
- Function Pointers in C: Syntax, Callbacks, and qsort (doc, Coddy Docs, 25 min)
It ties the syntax, typedef and callbacks to the qsort example you will actually use.
- How qsort Works in C — Sorting Any Type with Function Pointers (article, onlinecompilerc.com, 20 min)
It teaches the comparator contract, why `a - b` overflows, and how to reuse a comparator with bsearch.
- qsort() Function in C - GeeksforGeeks (article, GeeksforGeeks, 15 min)
It sets out the rules for comparison functions and the limits of the void* interface.
- Function Pointers & Callbacks (article, Embedded Interview Lab, 25 min)
It moves on to typedef style, null checks and dispatch tables that replace long switch chains.
- qsort - Quick Sort Algorithm in C - My Coding Notes (blog, My Coding Notes, 15 min)
It explains why a two-argument comparator forces global state, and how qsort_r passes context through an extra argument.
- Function pointer (reference, Wikipedia, 15 min)
It places C function pointers in the wider picture of other languages and performance trade-offs.
- Function object (reference, Wikipedia, 10 min)
It ends by showing how function objects carry state, which is the gap that plain C callbacks leave open.