Here is an example
char *pointer = “abc”;
if i try to change this string *(pointer+1)='D';
it returns 255 error, why?
Here is an example
char *pointer = “abc”;
if i try to change this string *(pointer+1)='D';
it returns 255 error, why?
The short answer is because that's in the definition of the language
The longer answer is that strings that are included in the program are part of the compiled program file, like the code itself. That is generally read-only in most modern operating systems. To make those strings writeable, the operating system or the language runtime would have to copy them into a writeable data block. Since that costs time and memory, and isn't usually what people want, C++ doesn't do it by default.