|
Multi-dimensional arrays of different sizes can be
passed to the same function argument using assumed-shape array.
#include
void func(int a[:][:]) // a is assumed-shape array
{
printf("a[1][1] = %d\n", a[1][1]);
}
int main() {
int a1[2][3] = {{1,2,3},
{4,5,6}};
int a2[3][4] = {{1,2,3,4},
{5,6,7,8},
{9,10,11,12}};
/* pass a1 and a2 with different sizes to func() */
func(a1);
func(a2);
return 0;
}
The output is:
a[1][1] = 5
a[1][1] = 6
|