A few mistakes. First, char *p[] does not declare an array pointer (what do you think it does) - it rather declares an array of char pointers.
Secondly, since x is an array, &x will be evaluated with the same numeric value as x (since arrays cannot be passed by value, only by a pointer, they are divided by pointers when passing the function), what you need to do is rather
const char *x = "Hello SO!"; const char **p = &x; printf("%s\n", *p);
This is a simple solution (creating a string literal, i.e. an array from char s, decaying to a pointer). There is another solution that requires a little more thought. From the compiler error message, you can see that type &x is equal to char (*)[] . So you should declare a pointer to an array here:
char x[] = "Hello SO!";
user529758
source share