Using the "sizeof" operator in an array column in C

Sorry for the newbie question, I'm still participating.

Say I have matrix[x][y]

Using sizeof(matrix)will return me the entire size of the array.

Using sizeof(matrix[a])will return me the size of a specific row.

Using sizeof(matrix[a][b])will return me the size of what is in [a] [b].

Is there a way to find the size of a column? If not, why? Am I missing something? Thank you for your time.

EDIT: Thanks for the help, if someone is looking for an answer, user "nnn" wrote the following:

The number of items in the column:

sizeof(matrix) / sizeof(matrix[a])

For the size in bytes occupied by the column:

sizeof(matrix) / sizeof(matrix[a]) * sizeof(matrix[a][b])

Weather Vane also explains how sizeof works:

sizeof , , , . , : . : no

+4
3

:

sizeof(matrix) / sizeof(matrix[a])   

, ( ), ( ) :

sizeof(matrix) / sizeof(matrix[a]) * sizeof(matrix[a][b])

sizeof, sizeof , , , .

, a b 0, .. matrix[0] matrix[0][0], .

+10

:

columnsize = sizeof(matrix) / sizeof(matrix[a])
0

If you want to find the size of the column, you must calculate this:

(number of rows)*(size of an element)

so for the matrix [x] [y] you have to write this:

int sizeOfArrayColumn = x*sizeof(matrix[0][0]);
0
source

Source: https://habr.com/ru/post/1617910/


All Articles