summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--funcptr.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/funcptr.c b/funcptr.c
index 478beca..33d4154 100644
--- a/funcptr.c
+++ b/funcptr.c
@@ -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);
}
-