In the second case (char *
), the string is in read-only memory. The correct type of string constants is const char *
, and if you used that type to declare the variable you would get warned by the compiler when you tried to modify it. For historical reasons, you're allowed to use string constants to initialize variables of type char *
even though they can't be modified. (Some compilers let you turn this historic license off, e.g. with gcc's -Wwrite-strings
.)