In the declaration char a[] = "Visual C++"
, a
is an array of 11 char
. So its size is 11 bytes.
In the declaration char *b = "Visual C++"
, b
is a pointer to char
. So its size is four bytes (in the C implementation you are using).
In the expression printf("%s", a)
, a
is also an array. However, it is automatically converted to a pointer to the first element of the array. So a pointer to char
is passed to printf
.
This conversion happens automatically unless an array is the argument of &
, sizeof
, or _Alignof
or is a string literal used to initialize an array of char
. Because it happens automatically, people tend to think of array names as pointers. However, they are not.
Incidentally, sizeof
is an operator, not a function.