print an n-dimensional array in c

Some tricky pointer arithmetic.

Turns out a really easy optimization if order doesn't matter much is to treat it like a single dimentional array of length d1 x d2 x d3 ... dn where d1 is the first dimention, etc. These two expressions are exactly equivalent in the way the memory is laid out, for instance: