0
char characterA = 'a';     
cout<<"Address of characterA: "<< static_cast<void *>(&characterA) <<endl;

Will display Memory Location on screen. How do I save that memory location into double or int variable ?

int memory_location = static_cast<void *>(&characterA) // <~~~ no work

~ thanks

Need_Help
  • 19
  • 4
  • By the way, he is referencing [this SO post](http://stackoverflow.com/questions/13535254/why-c-would-not-print-the-memory-address-of-a-char-but-will-print-int-or-bool), FYI. – Tim Biegeleisen Oct 26 '15 at 06:22
  • error: invalid conversion from 'char*' to 'int' [-fpermissive] – Need_Help Oct 26 '15 at 06:58
  • My I ask why you want to store the pointer address into an `int`? There is no guarantee that the pointer will fit into the `int`, depending on the architecture you are using. – Tim Biegeleisen Oct 26 '15 at 07:12
  • Have a look [here](http://stackoverflow.com/questions/9492798/using-intptr-t-instead-of-void). – Tim Biegeleisen Oct 26 '15 at 07:13

0 Answers0