1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include <stdio.h> void hello() { printf("こんにちは\n"); } int sum(int a, int b) { return a + b; } void higher_order_hello(void (*f)()) { f(); } int higher_order_sum(int (*f)(), int a, int b) { return f(a, b); } int main() { void (*hello_ptr)() = hello; int (*sum_ptr)() = sum; higher_order_hello(hello_ptr); int ret = higher_order_sum(sum_ptr, 2, 3); printf("%d\n", ret); return 0; } |
1 2 |
こんにちは 5 |