Note that if you can change the C code, you should change it to a multi-dimensional C array and you don’t need to compute the index yourself.
See either solution at Redirecting to Google Groups or Calling a c-function that returns a 2-dimensional array - #8 by yuyichao
Be careful about column/row ordering…
Somehow this question comes up much more often than I though…