0

Back then when I was a student, &obj was returning the address of the object.
I want to get the address of a simple char and tried all the methods I am aware of:

int main()
{
    using std::cout, std::endl;
    char a{ 'x' };
    char* p = &a;
    cout << std::addressof(a) << endl;
    cout << p << endl;
    cout << &a << endl;
}

This outputs:

x
x
x

Can someone explain what am I doing wrong?
How can I get the address of a?

Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76

0 Answers0