#include void missing_subscript_param(int a_param[][4][2], int first_subscript); void two_dimensions(int array[][2], int first_subscript); void contiguous_memory(int* ptr, int size); int main(int argc, char** argv) { // 3 sets of 4 sets of 2 integers int array[3][4][2] = { {{100,101}, {102,103}, {104,105}, {106,107}}, {{108,109}, {110,111}, {112,113}, {114,115}}, {{116,117}, {118,119}, {120,121}, {122,123}} }; // print 100-123 missing_subscript_param(array, 3); // pass in pointer to first element -- print 100 to 123 contiguous_memory(&array[0][0][0], 24); // declare a pointer to a 2 dimensional array of size 4 by 2 int (*variable)[4][2]; // when a multidimensional array is used in an expression it decays to a pointer to an array not including the first dimension variable = array; // we are passing in the 4x2 array which is offset into the pointer variable by the second index // print 116-123 two_dimensions(variable[2], 4); return 0; } // first subscript of multidimensional array parameter can be omitted // that allows different sizes to be passed in void missing_subscript_param(int a_param[][4][2], int first_subscript) { for (int i = 0; i < first_subscript ; ++i) { for (int j = 0; j < 4 ; ++j) { for (int k = 0; k < 2 ; ++k) { std::cout << "msp " << a_param[i][j][k] << std::endl; } } } } // print out contiguous memory void contiguous_memory(int* ptr, int size) { for (int i = 0; i < size ; ++i) { std::cout << "cm " << ptr[i] << std::endl; } } void two_dimensions(int array[][2], int first_subscript) { for (int i = 0; i < first_subscript ; ++i) { for (int j = 0; j < 2 ; ++j) { std::cout << "td " << array[i][j] << std::endl; } } }