Would it be undefined behavior to change where a pointer points, when its data is const? Example:
const char* p = \"foo\";
p = \"boo\";
I belie
The code in the first snippet is 100% correct. You have a pointer to const p
, which you repoint to something else. All good and in mint condition.
The second piece of code is ill-formed. You can't modify an object after removing the constness, if original object was const-qualified (which string literal is).