David542
David542

Reputation: 110432

Formal arguments for a multidimensional array

What is the suggested way to define function arguments for a nested array? For example, here are three possibilities:

int process(int (*coord)[2], size_t size)
{
   ...
}
int process(int coord[4][2], size_t size)
{
   ...
}
int process(int coord[][2], size_t size)
{
   ...
}

Are there all identical, or do any of these function arguments differ from the others?

Upvotes: 4

Views: 53

Answers (1)

chux
chux

Reputation: 154156

suggested way to define function arguments for a nested array?

All identical, follow your group's coding standard. user3386109 user3386109


Consider a 4th option that aligns with a new C2X new principle: "the size of an array appears before the array", if indeed that parameter size is meant in this way.

int process(size_t size, int coord[size][2]) {

Upvotes: 3

Related Questions