Skip to main content
A pointer to an array is a distinct derived data type in C that stores the memory address of an entire array, rather than pointing to a single element. It encapsulates both the base data type and the dimension of the array within its type signature. While typically associated with arrays of fixed compile-time sizes, C99 introduced Variable Length Arrays (VLAs), allowing pointers to arrays where the dimension is evaluated at runtime.

Syntax and Declaration

Because the array subscript operator [] has higher precedence than the dereference operator *, parentheses are mandatory when declaring a pointer to an array.
This must be strictly distinguished from an array of pointers, which omits the parentheses:

Initialization and Type Compatibility

When an array identifier is used in an expression, it typically decays into a pointer to its first element. However, when the address-of operator (&) is applied to an array identifier, it yields the address of the entire array.
While arr and &arr evaluate to the same memory address at runtime, their compile-time types and behaviors are fundamentally different:
  • arr has the compile-time type int[5]. In most expressions (with notable exceptions like sizeof(arr) and &arr), it decays into a pointer to its first element, yielding the type int *.
  • &arr applies the address-of operator directly to the array type, yielding a pointer to the entire array. Its type is int (*)[5].

Pointer Arithmetic

Pointer arithmetic is dictated by the size of the type being pointed to. Incrementing a pointer to an array advances the memory address by the total byte size of the entire array, not a single element.

Dereferencing and Element Access

To access individual elements through a pointer to an array, you must first dereference the pointer to yield the array itself. Due to operator precedence, the dereference must be enclosed in parentheses before applying the subscript operator.
Alternatively, using pointer arithmetic syntax:

Relationship to Multi-Dimensional Arrays

In C’s type system, a 2D array is an array of 1D arrays. When a 2D array identifier decays, it becomes a pointer to its first element—which is a 1D array. Therefore, a pointer to an array is the exact type yielded by the decay of a 2D array.

Function Parameters and Array Adjustment

The most critical application of pointers to arrays is passing multi-dimensional arrays to functions. When an array of arrays is declared as a function parameter, C automatically adjusts the parameter type to be a pointer to an array.
Because a 2D array like int matrix[3][5] decays into a pointer to its first element (int (*)[5]) when passed as an argument, the receiving function must accept a pointer to an array of the correct inner dimension. This ensures that pointer arithmetic within the function correctly skips over entire rows (e.g., matrix[1] advances the pointer by 5 * sizeof(int) bytes).
Tired of Poor C Skills? Fix That With Deep Grasping!Learn More