diff options
-rw-r--r-- | funcptr.c | 10 |
1 files changed, 2 insertions, 8 deletions
@@ -18,6 +18,8 @@ int half(int i) { return i / 2; } +static int (*fpv[])(int) = {doub, trip, half, NULL}; + void fpv_exec(int (**fpv)(int), int n) { int i; for (i = 0; *(fpv + i) != NULL; i++) { @@ -26,14 +28,6 @@ void fpv_exec(int (**fpv)(int), int n) { } int main(int argc, char **argv) { - int (**fpv)(int); - fpv = calloc(4, sizeof(int (*)(int))); - - fpv[0] = doub; - fpv[1] = trip; - fpv[2] = half; - fpv[3] = NULL; - for (argv++, argc--; argc; argv++, argc--) { fpv_exec(fpv, atoi(*argv)); } |