LOGBOOK

HELP

Quiz Entry - updated: 2026.07.10

What is a "multilevel" array (array of pointers), and how does it differ from a true 2D array?

A multilevel array like int *A[N] is an array of N pointers, each pointing to its own separate block — not one contiguous rectangle the way int A[N][M] is.

Array of pointers to ragged blocks

* int *A[N] is N independent pointers to separate, possibly ragged blocks — and a slot can be NULL. *

C's int matrix[3][4] is a true 2D array: 12 ints in one contiguous, row-major block, and the compiler computes any element's address arithmetically. A multilevel array is different — it's literally an array of pointers:

int *A[N];   // N pointers; each A[i] points somewhere else

Key differences and consequences:

  • Layout: the rows live in scattered allocations, not one block. A itself only stores the N pointers.
  • Ragged rows: because each pointer is independent, the pointed-to arrays can have different lengths — perfect for jagged data (e.g. a list of strings of varying length).
  • NULL entries: a pointer slot can be NULL to mark "no row here" (this is exactly how argv and a char *args[] list use a trailing NULL sentinel).
  • Extra indirection: reaching A[i][j] costs an extra memory access — first load the pointer A[i], then index into it — whereas a true 2D array needs none.
// Array of strings: classic multilevel array
char *names[] = {"Alice", "Bob", "Carol", NULL};
for (char **p = names; *p; p++)
    printf("%s\n", *p);

Tip: in a declaration, read right-to-left with cdeclint *A[N] is "A is an array of N pointers to int", not "pointer to an array". Use https://cdecl.org/ when in doubt.

Go deeper:

From Quiz: REVE1 / C Programming | Updated: Jul 10, 2026