Sizeof from multi-dimension arrays
new matrix[3][2] = [ [1, 2], [3, 4], [5, 6 ] ]
printf("%d %d", sizeof matrix, sizeof matrix[]);
3 2This works as expected:
new matrix[][] = [ [1, 2], [3, 4], [5, 6 ] ]
printf("%d %d", sizeof matrix, sizeof matrix[]);
3 2
This does not work (it is due to the fact that the size of the minor array is not the same for all members):
new matrix[][] = [ [1, 2, 3], [3, 4], [5, 6 ] ]
printf("%d %d", sizeof matrix, sizeof matrix[]);
3 0 //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
This works as expected:
new matrix[][7] = [ [1, 2, 3], [3, 4], [5, 6, 8, 9] ]
printf("%d %d", sizeof matrix, sizeof matrix[]);
3 7Last updated