I have the following code: I am inserting appropriate comments.
#include <stdio.h>
int main(void)
{
char *x = "Hello"; //x points to a constant string
*x = 'B'; //Runtime error
char str[10] = "Hello"; //String is not constant
x = str; //x now points to a non-constant string
*x = 'B'; //Hence this is allowed.
}
So is it that the value to which a pointer points is checked for its constantness at runtime, and an error is thrown accordingly.