Possible Duplicate:
constants and pointers in C
I have this little piece of code. I am using a gcc compiler:
#include <stdio.h>
int main()
{
const int a=10;
int *d;
d=&a;
*d=30;
printf("%d %d\n",a,*d);
return 0;
}
It gives a warning on compiling:
"assignment discards qualifiers from pointer target type"
But no error. The output is: 30 30
Then doesn't it defy the purpose of maintaining a const variable whose value is fixed throughout the program execution (please correct me if I am wrong)?