Array Arithmetic
For example if we have something like this
#include <stdio.h>
int main() {
int arr[] = {1,3,5};
printf("%p %d\n", arr + 2, *(arr + 2));
return 0;
}
0x16b852b40 5
When we do arr + 2
, it's basically the memory address of first element ofarr
+ 2 (so it's the memory address of 5
)
Hence:
arr + 2
returns a memory address of (5
) wherearr
is now pointing to1
*(arr + 2)
will return5