You can't do this:
char s[] = "string";
char *p = &s;
because
the name of an array is a pointer to the first element of that array. So
s
is already a pointer to a
char
, so
&s
is a pointer to a pointer to a
char
. You would need to change the type of
p
to use the address of
s
:
char s[] = "string";
char **p = &s;
This works:
char s[] = "string";
char *p = s;
because
s
is a pointer to a
char
, and so is
p