#include
int main()
{
const int a = 12;
int *p;
p = &a;
*p = 70;
}
Will it work?
yes, you can make it done by using such code. but the code do not apply when when a
is global (a gcc-compiled program gave me segmentation fault
.)
generally speaking, in beloved C, you can almost always find someway to hack things that are not supposed to be changed or exposed. const here being a example.
But thinking about the poor guy(maybe myself after 6 months) maintains our code, I often choose not do so.