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!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

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

24th May 2020, 4:19 PM
Win Htay 🇲🇲
Win Htay 🇲🇲 - avatar
3 Answers
+ 2
thanks sir!
24th May 2020, 4:26 PM
Win Htay 🇲🇲
Win Htay 🇲🇲 - avatar
+ 1
you should cast the address to a void * to make it print what you expect: cout << static_cast<void*>(&a);
24th May 2020, 4:22 PM
MO ELomari
+ 1
cout<<(void *) &c;
25th May 2020, 6:07 AM
PK Khan
PK Khan - avatar