Function pointers & Callbacks
Last updated
What is Function pointers & Callbacks?
A function pointer stores the address of a function, allowing that function to be called indirectly, passed as an argument, or stored in a data structure, similar to how a regular pointer stores the address of a variable. Callbacks use this to let one function invoke another that is decided at runtime, a pattern used by standard library functions like qsort, which takes a comparison function as a callback. This mechanism underlies more advanced patterns in C, including simulating object-oriented dispatch through structs containing function pointers.
Free resources to learn Function pointers & Callbacks
- ArticleFunction Pointers
- ArticleMaking Function Pointers Usable In C
- VideoFunction Pointers in C
More in stage 20: Idioms & Design Patterns
Function pointers & Callbacks: common questions
Can I learn Function pointers & Callbacks in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Function pointers & Callbacks in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Function pointers & Callbacks tutorial for beginners?
It is lesson 108 of 141 in the free C Programming roadmap, in stage 20, Idioms & Design Patterns. If you are new to C Programming, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.