I want to know the difference between local and global constants because I tried these examples and there are different results
in this example
#include <stdio.h>
const int x = 5;
int main()
{
int* ptr = &x;
*ptr= 10;
printf("%d",*ptr);
}
it returns segmentation fault
but in this example x changes and i know this way
#include <stdio.h>
int main()
{
const int x = 5;
int* ptr = &x;
*ptr= 10;
printf("%d",*ptr);
}