Pointer Arithmetic

Pointer arithmetic allows navigation through array elements or memory blocks.

int arr[] = {1, 2, 3};
int* p = arr;

cout << *(p + 1); // Output: 2
p++;
cout << *p;       // Now points to arr[1]

Pointer math depends on the data type size.

← PrevNext →