accessing address of char variable

i have declared 3 vars in my program
int a=10;
float b=123.4;
char c='a';

am trying to print the address of above three vars,for int and float am able to get the address how do i get the address of char variable.


cout<<&a; //for getting address of int varible

cout<<&b; //for getting address of float varible

when am saying cout<<&c

it is giving me the content of c i.e., a but not the address how do i get the address of char varible
The output operator threats the char pointer as a C-style string. Try:
 
cout << static_cast<void*>(&c)
OR:
1
2
void * addr = &c;
cout << addr;
@gungurthisrilatha
Or use printf()
1
2
	char ch = 'a';
	printf("%p",&ch);                     

Last edited on
Topic archived. No new replies allowed.