#include <stdio.h>
#include <stdlib.h>
#include <time.h>
static void printints(const void *a, size_t n) {
const int *p = a;
puts("`int` values in contiguous memory locations:");
while (n--) printf("%d ", *p++);
puts("");
}
int main(void) {
int foo[2][2][2][2][2], base = 1000;
size_t d0, d1, d2, d3, d4;
srand(time(0));
for (d2=0; d2<2; d2++) /* lines */
for (d4=0; d4<2; d4++) /* fun */
for (d0=0; d0<2; d0++) /* swap */
for (d1=0; d1<2; d1++) /* these */
for (d3=0; d3<2; d3++) /* for */
{
base += 100 + rand() % 900;
/* alternatively swap the array indexes */
foo[d2][d4][d0][d1][d3] = base;
}
printints(foo, sizeof foo / sizeof (int));
return 0;
}