I am trying to print address of a particular character variable , but the output is not satisfying.
int main()
{
char ch[]=“Abhishek”;
char c=‘A’;
char s=‘B’;
cout<<&s<<endl; // BAAbhishek is output
cout<<&c<<endl; // AAbhishek is output
cout<<&ch<<endl; // 0x6ffe00 is output
cout<<ch<<endl;
char *p = ch;
p+=4;
cout<<p<<endl;
}
In my view , the outputs in these cases should be
- B
- A
- Abhishek
respectively