I’d like to know how to get an array rows & columns size. For instance it would be something like this:
int matrix[][] = { { 2, 3 , 4}, { 1, 5, 3 } }
The size of this one would be 2 x 3. How can I calculate this without including other libraries but stdio or stdlib?
This has some fairly limited use, but it’s possible to do so with
sizeof.So,
Or define your own macro:
Or even:
But, be aware that you can’t pass around this
int[][]matrix and then use the macro trick. Unfortunately, unlike higher level languages (java, python), this extra information isn’t passed around with the array (you would need a struct, or a class in c++). Thematrixvariable simply points to a block of memory where the matrix lives.