How will you modify a const variable in c?



We can modify the const variable with the help of pointer.

void main(){
const int a=10;
int *ptr=(int *)&a;
*ptr=20;
clrscr();
printf("%d",a);
getch();
}

Output: 20

2 comments: