From 1b7572c7869453754816db308902c68cff78a053 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Mon, 19 Sep 2011 19:06:10 -0400 Subject: [PATCH] using only pointers instead of array indexing --- ex15.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ex15.c b/ex15.c index 1853556..3b4eb15 100644 --- a/ex15.c +++ b/ex15.c @@ -15,7 +15,7 @@ int main(int argc, char *argv[]) // first way using indexing for(i = 0; i < count; i++) { printf("%s has %d years alive.\n", - names[i], ages[i]); + *(names + i), *(ages + i)); } printf("---\n"); @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) // second way using pointers for(i = 0; i < count; i++) { printf("%s is %d years old.\n", - *(cur_name+i), *(cur_age+i)); + *(cur_name + i), *(cur_age + i)); } printf("---\n"); @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) // third way, pointers are just arrays for(i = 0; i < count; i++) { printf("%s is %d years old again.\n", - cur_name[i], cur_age[i]); + *(cur_name + i), *(cur_age + i)); } printf("---\n");