I am new to C, so it may be a dumb question. I was writing a piece of code like bellow:
char ar[]="test";
*(ar+1)='r';
this is working fine. But whenever I am doing it:
char *p="test";
*(p+1)="r";
this is giving segmentation fault. Can anyone please describe why second case is giving segmentation fault? explanation from memory point of view will be appreciated.