Formal arguments for a multidimensional array

Viewed 48

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?

1 Answers

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]) {
Related