diff options
-rw-r--r-- | funcptr.c | 14 |
1 files changed, 4 insertions, 10 deletions
@@ -22,18 +22,12 @@ int half(int i) { 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++) { - printf("%d\n", (*(fpv + i))(n)); - } + while (*fpv) + printf("%d\n", (*fpv++)(n)); } int main(int argc, char **argv) { - int i; - for (i = 1; i < argc; i++) { - fpv_exec(fpv, atoi(argv[i])); - } - + for (argv++, argc--; argc; argv++, argc--) + fpv_exec(fpv, atoi(*argv)); exit(EXIT_SUCCESS); } - |