I searched many similar questions, but none of them actually answer my question. I know the difference between char* and char[]. char* is a pointer, which can point to a string, and can be reassigned to another string, like this:
char* p;
p = "hello";
p = "world";
but the string p points to cannot be modified. char[] is an array, the element of the string in this array can be modified, like this:
char[] arr = "hello";
arr[0] = 'w'; // arr = "wello";
my question is that why arr cannnot be reassigned? like this:
arr = "world";
what is the relation between the name arr and the actual char[]? Based on my understanding, arr points to the starting position of char[], which means it is similar to a pointer, like p in the first example, but it also seems that arr itself does not have a memory address, unlike p. So, basically, I am quite confused about why arr cannot be assigned like a pointer but works like a pointer. I am looking forward to very detailed explanantions, thanks for help.