logo

Courses with this lesson

What are function pointers in C?

#include <stdio.h> #include <stdlib.h> #include <string.h> long long sum(int a, int b) { return a + b; } long long mul(int a, int b) { return a * b; } int main(int argc, char* argv[]) { long long (*fun)(int, int); fun = &add; printf("%lld\n", fun(5, 7)); fun = &mul; printf("%lld\n", fun(5, 7)); return 0; }