0

I have an array of char pointers and I want to know the address these pointer are pointing too. Essentially I want to know the address of the string the char pointer points to. enter image description here

I want to know How to get access to 0x555555769280 for example I can see it in the debugger, but I want to be able to print the address.

Adam Rich
  • 86
  • 2
  • 10

1 Answers1

3

When you try to print a pointer, the value stored will be printed instead of address because std::cout will treat char * as a null-terminated string and print the string. To get the address, you can cast it to a pointer. Try this:

cout<< (void *) ptr2[0];
user4581301
  • 33,082
  • 7
  • 33
  • 54