2d array rows/columns length C
arrays, c
Solution
`boardSize[0]` gives you the first row of the matrix, `boardSize[0][0]` the first of its elements. So the quantities you are looking for are `sizeof boardSize/ sizeof boardSize[0]` and `sizeof boardSize[0]/ sizeof boardSize[0][0]`.
BTW: use `size_t` as a type for sizes, not `int`.
Problem
I need to declare a 2d array to represent the size of chess-board. However, I'm having a trouble understanding how would I actually calculate the width and the length of the board. I would like to know how could I calculate size of the rows and columns of my 2d array Say, `int boardSize[5][5]`? ``` int main() { int boardSize[5][5]; int boardWidth=? int boardHeight =? createBoard(boardWidth, boardHeight); } int createBoard(int width, int height) { // code that actually creates board // } ``` Sorry, for not being specific in the begging. So, here I need to calculate boardwidth and boardheight variables? How do I do that from the declared array above. Thank you!