Wednesday 14 October 2015

How to change the value of a const variable in C language ?

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

No comments:

Post a Comment