0

I have this code, that gets the memory address of the integer myAge and then prints it out:

int myAge = 13;
cout << "myAge is stored at: " << &myAge << endl;

The result of that is a normal memory address, as expected. However when I try to apply the same method to a variable with type char, it gives a strange result:

char myGrade = 'A';
cout << "myGrade is stored at: " << &myGrade << endl;

Output:

A╠╠╠╠╠╠╠╠

Why is this happening?

carefulnow1
  • 803
  • 12
  • 30

0 Answers0