Created
June 16, 2014 11:56
-
-
Save mashcom/edcd86f6d99a327ac9f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(int argc, char * argv[]){ | |
int ages[]={12,56,23,34,51}; | |
char *name[]={"blessing","tawanda","prosper","simba","titi"}; | |
int count=sizeof(ages)/sizeof(int); | |
int i=0; | |
//retrieve names using for loop | |
for(i=0;i<count;i++){ | |
printf(" %s is %d years old \n",name[i],ages[i]); | |
} | |
printf("-------------------going to the pointer-------------------------------\n"); | |
//retrieve using pointers | |
int *cur_ages=ages; | |
char **cur_name = name; | |
for(i=0;i<count;i++){ | |
printf("%s is %d years old \n",*(cur_name+i),*(cur_ages+i)); | |
} | |
printf("----------------------------starting 2nd pointer----------------------------\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment