I read that constant values cant be changed but in this code below the value of i
is getting changed through the use of a pointer. May I know how?
#include <stdio.h>
int main()
{
const int i = 10;
int *ptr = &i;
*ptr = 20;
printf("%d\n", i);
return 0;
}
The output of this code is 20 with a compiler warning.