C
CBFalconer
Ron said:Nope, it evaluates to an array of char, which converts to pointer
to char. The characters are effectively const (it is undefined
behvaior to attempt to change them), but the type of the
expression is not const char*. (except when sizeof or & is
applied to the array value).
It's effectively the same in C++, except C++ defines a formal
array-to-pointer conversion.
However it is advisable to declare such strings as:
const char *foo = "foobar";
so that the C compiler can emit suitable warnings on misuse, such
as trying to alter it with such things as *foo = 'F'; Note that
foo = "barfoo"; is perfectly legal, except you may never find the
"foobar" string again.