const int a = 3; 3 0x7ffe87e48554 Can anyone explain why its giving output 3 while at same location im getting value 5.
const int *ptr_to_a = &a;
int *ptr;
ptr = (int*)ptr_to_a;
cout<<(*ptr_to_a)<<" "<
// changing here.
(*ptr) = 5;
cout<<(*ptr_to_a)<<" "<
Output is
3 0x7ffe87e48554
3 0x7ffe87e48554
5 0x7ffe87e48554
3 0x7ffe87e48554
5 0x7ffe87e48554
Loading
Rajanikant HawaldarPosted Jul 2, 2021, 6:21 AM