U
user
Hello,
Here is the program
#include stdio
int main(void)
{
const int num = 100;
int *ip;
ip = (int *)#
*ip = 200;
printf("value of num is %d(%d) \n", num, *ip);
}
Output:
value of num is 100(200)
The output says that *ip is changed and 'num' is unchanged. How is this
possible when both of them point to the same memory location? My wild guess
says that this trick is handled at the compiler level. Am I correct?
Even when the memory location is accessable and the contents changed the
'const integer' is unaffected.
Thanks
Here is the program
#include stdio
int main(void)
{
const int num = 100;
int *ip;
ip = (int *)#
*ip = 200;
printf("value of num is %d(%d) \n", num, *ip);
}
Output:
value of num is 100(200)
The output says that *ip is changed and 'num' is unchanged. How is this
possible when both of them point to the same memory location? My wild guess
says that this trick is handled at the compiler level. Am I correct?
Even when the memory location is accessable and the contents changed the
'const integer' is unaffected.
Thanks