0

Constant's are supposed to be in read-only memory ,then how is a pointer to const able to change its value .

#include<stdio.h>
int main(void){
const int c=10;
int* p=&c;

*p=1;

printf("c:%d",c);//value of const changed.
return 0;
}

Output: c:1

compiler:gcc 4.8.5

ashu
  • 71
  • 4

0 Answers0