Thanks for the help. I appreciate both of your replies.
I have two further questions about the following code:
Code:
#include <stdio.h>
int main(int argc, char *argv[]) {
int a[] = {1, 10, 100, 1000};
int *b = a;
char *c[] = {"hello", "how", "are", "you?"};
char **d = c;
printf("%d\n", *b);
printf("%d\n", *++b);
printf("%d\n", *++b);
printf("%d\n", *++b);
printf("%s\n", *d);
printf("%s\n", *++d);
printf("%s\n", *++d);
printf("%s\n", *++d);
while (--argc > 0)
printf("%s\n", *++argv);
return 0;
}
1) Why is it that I can manipulate argv, which is an array of char pointers, using ++ but couldn't do the same to c (in the original post)?
2) Is my way of using char **d sloppy at all? After reading
BEN10's answer, I had the idea of using a pointer to a pointer to a char, but I don't know if that is a convoluted way of doing things.
My goal with this little program is to understand pointers better and not use indexing, since I already understand how indexing works.
Thanks again for any help.