In the following code, why is not possible to do this dereferencing: *arr = 'e'. Shouldn’t the output be the character 'e'?
int main ()
{
char *arr = "abt";
arr++;
* arr='e'; // This is where I guess the problem is occurring.
cout << arr[0];
system("pause");
}
I am getting the following error:
Unhandled exception at 0x00a91da1 in Arrays.exe: 0xC0000005: Access violation writing location 0x00a97839.
In contrast:
This link and diagram explains “why”: