AsianDuckKing AsianDuckKing - 28 days ago 8
C Question

How can I understand int *a[5][5]?

I got a task to modify the content of a 2-dimensional array

int[5][5]
, I was given the definition
int *a[5][5]
and ordered to use a
int**
(the pointer of a pointer) to handle this task.

I'm now wondering the meaning of this
int *a[5][5]
, how can I understand the meaning of this and similar definitions?

Answer

int *a[5][5] is a 2D array of pointers. A pointer-to-pointer can be used to point at any pointer item in this array.

A for how to understand the declaration, everything left of the variable name is the type of each item in the array, in this case int*.

You could also use this site. It works for many C declarations, but not all.