To change the value of const defined variable in C you can use the following code. However in gcc this code might show segmentation fault.
int main {
const int a = 5;
printf("%d",a);
int *p;
p=&a;
*p=10;
printf("\n%d",a);return 0;
}
Output:
5
10
int main {
const int a = 5;
printf("%d",a);
int *p;
p=&a;
*p=10;
}
Output:
5
10
No comments:
Post a Comment