While learnng about pointer in C, I am getting Segmentation fault error in an online compiler because of changing value of a particular character of a stirng variable. I first tried it in my local compiler but it was printing nothing as output. What is the reason for the problem, and how can it be solved?
Code I write is :
#include <stdio.h>
int main(void)
{
char *a = "abcd";
a[0] = 'A';
printf("%s\n",a);
}
Output of online compiler :
Segmentation fault
Output of offline compiler was nothing.