Lesson 22 of 50
cFunction Pointers
11 mins
Course progress44%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 22 of 50
c11 mins
Keep these ideas in mind as you work through the lesson.
A function pointer stores the address of a function and can be invoked like a regular function.
int add(int a, int b) { return a + b; }
int (*op)(int,int) = add; // pointer to function
printf("%d
", op(2,3)); // prints 5
Useful for callbacks, tables of operations, and implementing polymorphism in C.