The variable i
is declared const but still I am able to change the value with a pointer to the memory location to it. How is it possible?
int main()
{
const int i = 11;
int *ip = &i;
*ip=100;
printf("%d
",*ip);
printf("%d
",i);
}
When I compile, I get this warning :
test.c: In function ‘main’:
test.c:11: warning: initialization discards qualifiers from pointer target type
Output is this
100
100
See Question&Answers more detail:os