I tried running the following program:
#include <iostream>
using namespace std;
int main(){
char *x = "Linux";
*x = 'T';
cout<<"value: "<<*x<<endl;
}
According to me, it should have stored 'T' in the location pointed to by x. But instead it gave segmentation fault. But when I did:
char *x;
*x = 'T';
The output was as expected. Can somebody explain this behavior?