Why is address of char data not displayed?
CPP Webinar : Pointers [17-Feb-2018]
This is a special case. When you are taking the address of a char data, you get char * . operator<< interprets that as a C string, and tries to print a character sequence instead of its address.
When you are taking the address of b, you get char * . operator<< interprets that as a C string, and tries to print a character sequence instead of its address.
Try cout << “address of char :” << (void * ) &b << endl instead
why are &character treated as different and what are reason?
I have already mentioned above. Say you store a character in a variable b. Now &b will return a character pointer. So the compiler interprets it as a C string and prints the same character. This is a special case and you can avoid it explicitly by using (void * )