How to get row and column from index?

For a zero-based index, the two operations are, where width is the width of the structure:

row    = index / width
column = index % width

Those are for C using integers, where the division rounds down and the % modulo operator gives the remainder. If you’re not using C, you may have to translate to the equivalent operations.

If you don’t have a modulo operator, you can use:

row    = index / width
column = index - (row * width)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)