You are passing char **
twice where char*
is expected.
&b
takes the address of b
, with b
being a char*
, the address of a char
. So &b
is char **
. The same issue appears for a
.
Update:
Just saw b
isn't an array but a pointer which points to a "string"-literal. The latter are constant, you cannot change them, so copying to a literal's address (what the code actually does not, because of the misplaced &
-operator in frot of the b
) has to fail.
To get around this define b
like this
char b [] = "World\n";
Is that because arrays are always char** [...]
Arrays aren't "always char **
".
If an array is passed as argument to a function it decays to a pointer to it's first element. So
char b[] = "test";
would decay to a
char * pb
with pb
pointing to the char
't'
, the first characters of `"test".