#include <stdio.h> int sum(int a, int b) { return a+b; } int minus(int a, int b) { return a-b; } int x(int a, int b) { return a*b; }
//第一个参数为指向函数的指针,返回类型为int,参数是int,int
void counting(int (*p)(int, int), int a, int b) { int result = p(a, b); printf("result = %d\n", result); } int main() { //指向函数的指针 counting(sum, , );//counting(minus, 1, 2); counting(x, 1, 2); ; }