I've training / homework to create the following formula applied to C:
How to calculate the address to an element in a matrix of integers, if the starting address of the matrix is known, the size is known and the row and the columns of the element is known.
Say the matrix is a[b][c].
The starting address is then a
or equivalently &a[0][0]
Numbers of rows is b.
Number of columns is c.
Every element should have size sizeof(int)
so then the address would be a + b*sizeof(int) + a*sizeof(int)
Is this formula correct?