I don't get the address of a character variable in c++ in the following. char c; cout<<&c; Please explain why? Thanks! | SoloLearn: Learn to code for FREE!

+3

I don't get the address of a character variable in c++ in the following. char c; cout<<&c; Please explain why? Thanks!

c++

5/24/2020 4:19:03 PM

Win Htay

3 Answers

New Answer

+1

you should cast the address to a void * to make it print what you expect: cout << static_cast<void*>(&a);

+1

thanks sir!

+1

cout<<(void *) &c;