being able to modify something depends whether your pointer allows it and whether you string allows it.
if you declare pointer like
char const *p; you can only use it for reading and accessing different elements of different arrays. but you can not change them using p even if they are arrays of simple chars.
char a = "Hello world!"; char const *p; p = a; (*p) = 'E'; // This is not allowed a = 'G'; // But you are free to use this
if your string is declared like
char const a; it cannot be modified using function like
strcpy() nor can you change single element using
a = 'E'; because it is declared constant. so if you want to modify
char const a; , you must use a pointer that has type
const char ):
char const a = "CONSTANT!"; // Not editable with simple assignment like a = 'R'; or function like strcpy(); // But char *p; p = a; // And you can play with a if you want *p = '0';
you must ensure that pointer points to type char and not const char.
when you say:
char *p = "pointer"; compiler interprets this same as:
char const *p = "pointer"; , and that is why you cannot edit in this case - it is pointer used to point const chars (plus, literal constant - "pointer" - is not editable with other pointers because it is stored somewhere in the memory where your program cannot access)