The best way is the const char*
that conveys the idea that the pointer can point to other thing but the thing it points to is constant (string literals are expected not to be modified by the standard. Standard says it is undefined behavior in trying to do so.)- cant be modified. Second will generate warning. This is a risk that you will leave open.
Also the main thing is - those are commonly kept in read only section but that might vary given that standard doesn't put any constraint other than the fact modifying them is undefined behavior. How that will be realized is a big choice left to implementors. One can simply do this also - that memory on which literal is kept is not read only but modifying them invokes behavior dependent on that platform.
Also are these statements true? is a question which has lots of things to be specified. The platform on which you are running
and what architecture is there.
Literal strings are not const char[]
arrays, but only char[]
arrays that are forbidden to be overwritten. You can realize the behavior without storing them in read only memory too. But depending on the declaration segregating the memory location where it is stored is convoluted design - rather it's better to keep it in same memory irrespective of declaration for the same string literal(that is the case in most cases).