Methods of getting an address of array element with gdb

Viewed 33

Let's say we have an array

char arr[10] 

Why are these not the same? gdb outputs different address.

display/w &arr[10] - /x &arr+10 = 0x7ffc85c8b9f4
display/w &arr+10 -  /x &arr[10] = 0x7ffc85c770f9

I understand these as

  1. The address of the tenth element of arr.
  2. The address of the tenth byte of arr, where a char is 1 byte.
0 Answers
Related