I was wondering why it is allowed to modify a constant using a pointer?
int main( int argc, char ** argv ) {
const int my_const = 9;
int *ptr = &my_const;
*ptr += 10;
printf("%d", my_const);
return 0;
}
This prints 19 without any error.
Is this a compiler specific behavior? (I am running gcc 4.7 on Windows)
Thanks...