int main()
{
constint i = 42;
*(int*)&i = 43; // What is happening here
printf ("i %d,%d,%d",i,*(&i),*(int*)&i); // Why the result is 42 42 and 43
return 0;
}
please see the comments. why the result is 42 42 43
the problem is that you're removing const. If you're writing this 'i' or '*(&i)' the compiler knows that it's the constant 42 and replace the expressing accordingly. When you cast away the const it uses the variable which is set to 43 previously.