previous | start | next

## Arrays and Pointers

- There is an intimate connection between arrays and pointers in C++.
- The name of an array is a pointer to the starting element.

  >     int a[10];
  >     int* p = a; // now p points to a[0];
  >     *a = 12; // same as a[0] = 12;

- You can add an integer to offset to the pointer to point to another array location (pointer arithmetic).

  >     *(a + 3) means the same as a[3]

- This relationship is called the array/pointer duality law. For any integer `n`,

  >     *(a + n) means the same as a[n]

previous | start | next