- 450 名前:デフォルトの名無しさん mailto:sage [2014/01/14(火) 21:41:05.82 ]
- #include <stdio.h> /* >>419 two3.c */
typedef int (*INT_FUNCTION)(int, int); int x_function(int a, int b){ int x = a * b; return x; } int sum_function(int a, int b){ int sum = a + b; return sum; } void two_three(INT_FUNCTION p){ printf("answer = %d\n", p(2, 3) ); } int main(int argc, char *argv[]){ INT_FUNCTION p; if(argc == 2 && *argv[1] == 'x') { p = x_function; } else { p = sum_function; } two_three(p); return 0; } /* C:\work>two3 answer = 5 C:\work>two3 x answer = 6 */
|

|