If I do:
const char* const_str = \"Some string\"; char* str = const_cast(const_str); // (1) str[0] = \"P\"; // (2)
Where (wh
You are attempting to modify a constant string which the compiler may have put into a read-only section of the process. This is better:
char str[32]; strcpy(str, "Some string"); str[0] = "P";