12345678910111213141516171819202122 |
- #include <stdio.h>
- /* Add two integers */
- int add (int a, int b) {
- return a + b;
- }
- /* a function that takes a function pointer */
- int add2 (int (*pAdd) (int, int)) {
- return (* pAdd)(2, 3);
- }
- int
- main () {
- int (* pAdd)(int, int);
- pAdd = &add;
- int sum = (*pAdd)(2, 3);
- printf ("Sum is %d\n", sum);
- return 0;
- }
|