Is int *array[32] a pointer to an array of 32 ints, or an array of 32 pointers to int? Does it matter?

arrays, c, multidimensional-array, pointers

Solution

When in doubt - ask `cdecl`

$> cdecl 
Type `help' or `?' for help
cdecl> explain int *columns[32]
declare columns as array 32 of pointer to int

EDIT In response to comments: I found cdecl source on Google Code Search. It requires GNU readline library. I think it shouldn't be a problem to compile it on Mac OS X or Windows.

Problem

If I write ``` int *columns[32]; ``` am I defining an array with 32 pointers to `int`s? Or is it a pointer to an array of 32 `int`s? How do I differentiate between the two? Is there a difference?

Original source