I have code equivalent to the following:
const int* const n = new int;
printf("input: ");
scanf("%d", n);
delete n;
Now, since n is a pointer to a CONSTANT integer, this shouldn't work (I'm expecting a compiler error). However, this seems to work properly and even stores the value of the input into *n.
I want to know, why doesn't this give me an error; why does it work? Shouldn't scanf be unable to alter the value of *n?