In C I'd do the following, try:
sizeof( matrix ) /sizeof( matrix[0] ) <- outer array
sizeof( matrix[0] )/ sizeof( matrix[0][0] ) <- inner array
linux ~ $ cat sizeof_test.c
#include <stdio.h>
int main( void )
{
int matrix[][3] = { {1,2,3}, {1,2,3}, {1,2,3}, };
int matrix2[][3] = { {1,2,3}, {1,2,3}, {1,2,3}, {1,2,3}, };
int matrix3[][4] = { {1,2,3,4}, {1,2,3,4}, {1,2,3,4}, {1,2,3,4}, };
printf( "array (%d) - elements( %d )\n", sizeof( matrix ) /sizeof( matrix[0] ), sizeof( matrix[0] )/ sizeof( matrix[0][0] ));
printf( "array (%d) - elements( %d )\n", sizeof( matrix2 ) /sizeof( matrix2[0] ), sizeof( matrix2[0] )/ sizeof( matrix2[0][0] ));
printf( "array (%d) - elements( %d )\n", sizeof( matrix3 ) /sizeof( matrix3[0] ), sizeof( matrix3[0] )/ sizeof( matrix3[0][0] ));
return 0;
}
linux ~ $ gcc sizeof_test.c -o sizeof_test
linux ~ $ ./sizeof_test
array (3) - elements( 3 )
array (4) - elements( 3 )
array (4) - elements( 4 )
linux ~ $