Suppose that I have an array of pointers:
char *names[] = { "Za" , "John"};
Can I declare it like this:(?)
char **names = { "Za" , "John" }
The reason I am trying to do this is that I am trying to increment the array to print its contents such that I can do:
printf("%s \n" , *(++names))
So I can get printf to print "John".
I tried the declaration char **names and I got the following warning upon compilation:
test.c: In function ‘main’:
test.c:6:2: warning: initialization from incompatible pointer type [enabled by default]
char **names = { "Za" , "John"};
^
test.c:6:2: warning: (near initialization for ‘names’) [enabled by default]
test.c:6:2: warning: excess elements in scalar initializer [enabled by default]
test.c:6:2: warning: (near initialization for ‘names’) [enabled by default]
P.S my C file name is test.c
Thanks.
charis not and can never be the same as an array of pointers tochar.