The type of string
is char[6]
, it is an array of char
, and you can assing it to a char pointer:
char* p = string;
However the type of &string
is char(*)[6]
. It is a pointer to an array of 6 char
, so you cannot assign it to char**
, which is a pointer to a pointer to char
. You need to assign it to a pointer to an array of 6 characters:
char (*pa)[6] = &string;
Thus the cast you made here:
(String*)try;
which is equivalent to:
( char**)try
Is incorrect, because try
represents a pointer to an array of 6 char, and not a pointer to a pointer to char.
The pointer should be cast to the correct type, a pointer to an array of 6 char:
String* try2 = *( char(*)[6] )try;