I am printing the addresses of variables in the following code snippet.
int int1=3;
char ch1='f';
printf("address int1 %llX\n",&int1);
printf("address ch1 %llX\n",&ch1);
cout<<"address int1 "<<&int1<<endl;
cout<<"address ch1 "<<&ch1<<endl;
Here is the output:
address int1 7FFF47D7C0F0
address ch1 7FFF47D7C0E8
address int1 0x7fff47d7c0f0
address ch1 f@
My question is Why cout prints the contents of the character rather than its address in this example? However, printf displays the addresses as shown above. Furthermore, the following also displays the address correctly:
cout<<"address ch1 "<<(void*)&ch1<<endl;