Thanks. I tried it tonight and got my little square grid. For debugging I printed out the memory each character took using lx%.
eg.
grid[0][0] = 9fcba864
grid[1][0] = 9fcba865
grid[2][0] = 9fcba866 and so on...
I know that this is hexadecimal, but from it can you determine where this memory exists in your pc system, say if you had 1Gb ram? ie, does the value show how high up the chain it is?
Code:
#include <stdio.h>
#define ROWSIZE 8
#define COLSIZE 8
int main()
{
char grid[ROWSIZE][COLSIZE];
initializeGameGrid(grid, ROWSIZE, COLSIZE);
printGameGrid(grid, ROWSIZE, COLSIZE);
return 0;
}
initializeGameGrid(char grid[ROWSIZE][COLSIZE], int rowsize, int colsize)
{
int i,j;
/* initialise gameboard with dots down by row and column */
for(i=0; i<rowsize; i++)
for (j=0; j<colsize; j++){
grid[i][j] = '0';
printf("Address at grid %d,%d is: %lx\n",i,j,&grid[i][j]); /* testing */
}
}
printGameGrid(char grid[ROWSIZE][COLSIZE], int rowsize, int colsize)
{
int i,j;
/* position and center grid */
printf("\n\n ");
for(i=0; i<rowsize; i++)
for(j=0; j<colsize; j++){
printf("%c",grid[i][j]);
if(j == colsize-1) /* at end of a row (last column) put a CR */
printf("\n ");
}
}