I have the following C code:
char arr[1];
printf("%p %p\n", &arr, arr);
The values of &arr and arr printed are always the same. This means that arr contains the location of itself.
If I dereference the array and write a value to it like so:
*arr = 'a';
I expect it to overwrite the value in arr because arr points to itself.
But this doesn't happen. When I print the value of arr again:
printf("%p\n", arr);
It contains the same old value which is the location to itself.
Why doesn't arr get overwritten?
Edit: I tried the following links but none of them answered my question exactly: