Decay of multidimensional arrays as function parameters

  • A+

I know that for example this:

void foo(int a[])// or a[x] 

will be considered by the compiler like this:

void foo(int *a) 

But I don't know, and I didn't found anywhere how are multidimensional arrays seen by the compiler

For example:

void foo(int a[3][4]) 

Will it be something like this?

void foo(int (*a)[4]) 

Or something like this?

void foo(int **a) 


When an array decays, it converts into a pointer to the first element. In the case of int a[3][4], a is an array of int[4], so a pointer to an element of int [3][4] has type int (*)[4].

So this:

void foo(int a[3][4]) 

Is the same as:

void foo(int (*a)[4]) 


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: