Behaviour of volatile keyword c++

2

What effect does volatile have on pointers? I got some unexpected behavior while using it

int main() {

volatile uint32_t *ptr=((uint32_t *)(0x00000000+0x00100100));
cout<<ptr<<endl;

uint32_t *ptr1=((uint32_t *)(0x00000000+0x00100100));
cout<<ptr1<<endl;

return 0;
}

"ptr" returns value 1, while "ptr1" return value 0x100100.

What causes this difference?

c++
pointers
volatile
asked on Stack Overflow Feb 25, 2019 by Yash Gupta

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0