C function pointers and callbacks: behaviour as data

12 steps · about 3 h 25 min · Intermediate

  1. 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.

  2. Function Pointers (video, YouTube, 15 min)

    A worked demo of declaring and calling function pointers, plus callback use cases, reinforces the reading.

  3. Function Pointer in C - Sanfoundry (article, Sanfoundry, 15 min)

    It covers declaration, assignment, callbacks as arguments and arrays of function pointers in one place.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

  8. qsort() Function in C - GeeksforGeeks (article, GeeksforGeeks, 15 min)

    It sets out the rules for comparison functions and the limits of the void* interface.

  9. 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.

  10. 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.

  11. Function pointer (reference, Wikipedia, 15 min)

    It places C function pointers in the wider picture of other languages and performance trade-offs.

  12. 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.