Hello,
can anyone tell me what will happen if const. var are changed through pointers and directly.
Iam getting a strange behaviour from 2 compilers.
1. with gcc on solaris-
const int i=9;
i=8;
printf("%d",i);
// it printf 8 but gives the compile time warning that writing on read only mem.
the same thing with cc on HP unix gives error.
but with use of pointers like this.
const int i=9;
int *p=&i;
*p=8;
works properly.
if const variables can be changed like this then whats the use of const. var.