char i[6] = "Hello"; //EXAMPLE 1
const char *p = "Hello"; //EXAMPLE 2
char q[6] = i; //EXAMPLE 3
char s[6] = (*(&i)); //EXAMPLE 4
"Hello"
is a string literal, which has a type of const char[6]
which is converted to
const char*
( like in EXAMPLE 2 )
1 - Why does not this conversion happen in EXAMPLE 1 ?
2 - How can a value of type const char[6]
be used to initialize an entity of type char[6]
( in EXAMPLE 1 ) ?
3 - EXAMPLE 3 will cause an error because of Array-to-pointer decay
, right ?
4 - EXAMPLE 4 will cause an error because of Array-to-pointer decay
, right ?