summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--funcptr.c16
-rw-r--r--funcptrptr.c86
2 files changed, 51 insertions, 51 deletions
diff --git a/funcptr.c b/funcptr.c
index dc4aaf3..9bf33c2 100644
--- a/funcptr.c
+++ b/funcptr.c
@@ -8,26 +8,26 @@ static int (*fpv[4])(int);
void fpv_exec(int (**)(int), int);
int doub(int i) {
- return i * 2;
+ return i * 2;
}
int trip(int i) {
- return i * 3;
+ return i * 3;
}
int half(int i) {
- return i / 2;
+ return i / 2;
}
static int (*fpv[4])(int) = {doub, trip, half, NULL};
void fpv_exec(int (**fpv)(int), int n) {
- while (*fpv)
- printf("%d\n", (*fpv++)(n));
+ while (*fpv)
+ printf("%d\n", (*fpv++)(n));
}
int main(int argc, char **argv) {
- for (argv++, argc--; argc; argv++, argc--)
- fpv_exec(fpv, atoi(*argv));
- exit(EXIT_SUCCESS);
+ for (argv++, argc--; argc; argv++, argc--)
+ fpv_exec(fpv, atoi(*argv));
+ exit(EXIT_SUCCESS);
}
diff --git a/funcptrptr.c b/funcptrptr.c
index fdc1542..810764e 100644
--- a/funcptrptr.c
+++ b/funcptrptr.c
@@ -9,70 +9,70 @@ void fpvv_exec(int (***fpvv)(int), int n);
void fpvvv_exec(int (****fpvvv)(int), int n);
int doub(int i) {
- return i * 2;
+ return i * 2;
}
int trip(int i) {
- return i * 3;
+ return i * 3;
}
int half(int i) {
- return i / 2;
+ return i / 2;
}
void fpv_exec(int (**fpv)(int), int n) {
- int i;
- for (i = 0; *(fpv + i) != NULL; i++) {
- printf("%d\n", (*(fpv + i))(n));
- }
+ int i;
+ for (i = 0; *(fpv + i) != NULL; i++) {
+ printf("%d\n", (*(fpv + i))(n));
+ }
}
void fpvv_exec(int (***fpvv)(int), int n) {
- int i;
- for (i = 0; *(fpvv + i) != NULL; i++) {
- fpv_exec(*(fpvv + i), n);
- }
+ int i;
+ for (i = 0; *(fpvv + i) != NULL; i++) {
+ fpv_exec(*(fpvv + i), n);
+ }
}
void fpvvv_exec(int (****fpvvv)(int), int n) {
- int i;
- for (i = 0; *(fpvvv + i) != NULL; i++) {
- fpvv_exec(*(fpvvv + i), n);
- }
+ int i;
+ for (i = 0; *(fpvvv + i) != NULL; i++) {
+ fpvv_exec(*(fpvvv + i), n);
+ }
}
int main(int argc, char **argv) {
- int (****fpvvv)(int);
- fpvvv = calloc(2, sizeof(int (***)(int)));
+ int (****fpvvv)(int);
+ fpvvv = calloc(2, sizeof(int (***)(int)));
- fpvvv[0] = calloc(2, sizeof(int (**)(int)));
- fpvvv[1] = calloc(2, sizeof(int (**)(int)));
+ fpvvv[0] = calloc(2, sizeof(int (**)(int)));
+ fpvvv[1] = calloc(2, sizeof(int (**)(int)));
- fpvvv[0][0] = calloc(4, sizeof(int (*)(int)));
- fpvvv[0][1] = calloc(4, sizeof(int (*)(int)));
- fpvvv[1][0] = calloc(4, sizeof(int (*)(int)));
- fpvvv[1][1] = calloc(4, sizeof(int (*)(int)));
+ fpvvv[0][0] = calloc(4, sizeof(int (*)(int)));
+ fpvvv[0][1] = calloc(4, sizeof(int (*)(int)));
+ fpvvv[1][0] = calloc(4, sizeof(int (*)(int)));
+ fpvvv[1][1] = calloc(4, sizeof(int (*)(int)));
- fpvvv[0][0][0] = doub;
- fpvvv[0][0][1] = trip;
- fpvvv[0][0][2] = half;
- fpvvv[0][0][3] = NULL;
- fpvvv[0][1][0] = doub;
- fpvvv[0][1][1] = trip;
- fpvvv[0][1][2] = half;
- fpvvv[0][1][3] = NULL;
- fpvvv[1][0][0] = doub;
- fpvvv[1][0][1] = trip;
- fpvvv[1][0][2] = half;
- fpvvv[1][0][3] = NULL;
- fpvvv[1][1][0] = doub;
- fpvvv[1][1][1] = trip;
- fpvvv[1][1][2] = half;
- fpvvv[1][1][3] = NULL;
+ fpvvv[0][0][0] = doub;
+ fpvvv[0][0][1] = trip;
+ fpvvv[0][0][2] = half;
+ fpvvv[0][0][3] = NULL;
+ fpvvv[0][1][0] = doub;
+ fpvvv[0][1][1] = trip;
+ fpvvv[0][1][2] = half;
+ fpvvv[0][1][3] = NULL;
+ fpvvv[1][0][0] = doub;
+ fpvvv[1][0][1] = trip;
+ fpvvv[1][0][2] = half;
+ fpvvv[1][0][3] = NULL;
+ fpvvv[1][1][0] = doub;
+ fpvvv[1][1][1] = trip;
+ fpvvv[1][1][2] = half;
+ fpvvv[1][1][3] = NULL;
- for (argv++, argc--; argc; argv++, argc--) {
- fpvvv_exec(fpvvv, atoi(*argv));
- }
+ for (argv++, argc--; argc; argv++, argc--) {
+ fpvvv_exec(fpvvv, atoi(*argv));
+ }
- exit(EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
}