Pointers are always a great source of confusion in C Programming. Here I have included two programs which might help you learn more about pointer arithmetic.
Program 1
int main() { char *list[] = {"first", "second", "third", NULL}; char** p; for(p=list; *p != NULL; p++) { printf("%s\n", p[0]); } return 0; }
Program 2
int main() { char* list[] = {"one", "two", "three", NULL}; char** p; for(p=list; *p != NULL; p++) { printf("%s\n", *p); } return 0; }
No comments:
Post a Comment