summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-12-10 16:13:14 +1300
committerTom Ryder <tom@sanctum.geek.nz>2019-12-10 16:13:14 +1300
commit9f60deecee488e4c16fefb3e82b4b7fbc9b4bb8d (patch)
tree3607fa610be0c097916bf8db5445981b0cc6bc50
parentRemove some unneeded brackets (diff)
downloadfuncptr-9f60deecee488e4c16fefb3e82b4b7fbc9b4bb8d.tar.gz
funcptr-9f60deecee488e4c16fefb3e82b4b7fbc9b4bb8d.zip
Use more idiomatic vector iteration
-rw-r--r--funcptrptr.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/funcptrptr.c b/funcptrptr.c
index 17864a0..f52719d 100644
--- a/funcptrptr.c
+++ b/funcptrptr.c
@@ -22,20 +22,20 @@ int half(int i) {
void fpv_exec(int (**fpv)(int), int n) {
int i;
- for (i = 0; *(fpv + i) != NULL; i++)
- printf("%d\n", (*(fpv + i))(n));
+ for (i = 0; fpv[i]; 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);
+ for (i = 0; fpvv[i]; 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);
+ for (i = 0; fpvvv[i]; i++)
+ fpvv_exec(fpvvv[i], n);
}
int main(int argc, char **argv) {