@ everybody
So as not to be contrary here is the routine that I came up with. No problems yet, but only time will tell. ;-)
/* number_of_dimensions is an int that holds the number of dimensions of the array (clever eh?), i is the standard counter variable. address holds the memory location. The element_values[] array is number_of_dimensions in size and holds the desired position of the element that we wish to address : i.e. (2,4,1,5) . The max_element_size[] array is also number_of_dimensions in size but it holds the maximum values of each of the dimensions: i.e. (10,10,10,10).
i = number_of_dimensions;
place_value = 1;
address = element_values;
i, element_values, address);
i--;
while (i >= 0) /* While there are more dimensions to calculate. */
{
place_value *= max_element_size[i + 1];
address += element_values * place_value;
i--;
}
address *= type_size;
address += base;
And that's about it.
Cheers.