0

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.
so:

char a[15] = "Hello world!";
char const *p;
p = a;
(*p) = 'E'; // This is not allowed

a[5] = 'G'; // But you are free to use this

if your string is declared like char const a[10]; it cannot be modified using function like strcpy() nor can you change single element using a[5] = 'E'; because it is declared constant. so if you want to modify char const a[10]; , you must use a pointer that has type char (not const char ):

char const a[10] = "CONSTANT!"; // Not editable with simple assignment like a[3] = '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)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.