/* Simple program to demonstrate some memory mgmt issues */ /* Written by Carey Williamson March 22, 2010 */ #include #define ROWS 8 #define COLUMNS 8 /* Outer loop iterations */ #define HOWMANYTIMES 1 /* Verbose debugging output */ #define VERBOSE 1 /* Choose between printing addresses or values of each element */ /* #define ADDRESSES 1 */ int mymatrix[ROWS][COLUMNS]; int main() { int i, j, k; /* Initialize some values */ for(k = 0; k < HOWMANYTIMES; k++ ) { for( i = 0; i < ROWS; i++ ) { for( j = 0; j < COLUMNS; j++ ) { mymatrix[i][j] = i*COLUMNS + j; } } } #ifdef VERBOSE /* print it out for all to see*/ printf("Here is your beautiful matrix:\n"); for( i = 0; i < ROWS; i++ ) { printf("Row %2d: ", i); for( j = 0; j < COLUMNS; j++ ) { #ifdef ADDRESSES printf(" %x", &mymatrix[i][j]); #else printf(" %2d", mymatrix[i][j]); #endif } printf("\n"); } #endif }