Function pointer | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Function pointer

Unable to understand function pointer and it's application.

17th Jun 2020, 4:40 PM
Rahul Singh
Rahul Singh - avatar
2 Answers
Mainly used for callback mechanism and events of the components. Read these answers:
18th Jun 2020, 2:40 AM
Vasile Eftodii
Vasile Eftodii - avatar
They're often use for generics in C. An example of that would be qsort() which accepts a function pointer to do comparisons between any two types. You can also embed them in a structure if that function pointer is accessed frequently for that structure and you don't want to pass it as an argument to every function that requires it. It would then emulate class function calls in OOP.
18th Jun 2020, 11:09 AM
Gen2oo - avatar