What are multidimensional arrays

What are multidimensional arrays? I need to code a word jumble game but I have to use them and I don't know what they are.
a slow way to access memory :)

int md[10][10]; //10 "rows" and 10 "columns" for 100 total integers.

you can keep going

int md[10][10][100][20]; //a messy 4d array.

you can do this by nesting vectors as well...

while humans think of these as rows and columns usually, you can also try to think of them as an array of arrays. This is seen easily with arrays of strings, where each string is really just an array of characters.

the computer lays them out as one block of memory. Looks like row1col1, row1col2, ... rowncoln. The multiple dimensioning is done by computing the offset into a 1d array. It is just a crutch for humans to make the data match the conceptual understanding of what it represents.

Last edited on
a slow way to access memory :)
It's possibly slower only if done in the wrong order, and even then, maybe not. Depends what's going on around it.

A nested vector is not strictly equivalent. The contents of the inner arrays are not all contiguous.
Topic archived. No new replies allowed.