Nov 4, 2010 at 10:42pm UTC
The function InitializeBoard should
· Have the prototype
o bool InitializeBoard(int** connectNBoard, int numRowsInBoard );
· Initialize the connectNBoard to be have an 0in each element
· For example after initialization a 8X8 or 10X10 board would have the following values in the array connectNBoard
· Note that the numbers down the left side and across the top of labels, they are not part of the ConnectN board and are show for reference only
0 1 2 3 4 5 6 7 8 9
0 0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0 0 0
5 0 0 0 0 0 0 0 0 0 0
6 0 0 0 0 0 0 0 0 0 0
7 0 0 0 0 0 0 0 0 0 0
8 0 0 0 0 0 0 0 0 0 0
9 0 0 0 0 0 0 0 0 0 0
Here is what I did:
bool InitializeBoard(int** connectNBoard, int numRowsInBoard )
{
int row;
int col;
int i, j;
int numRows;
int* myConnectNBoard;
for(row=0; row<=numRowsInBoard; row++)
{
for(col=0; col < numRowsInBoard; col++)
{
myConnectNBoard[row][col] = 0;
}
}
char blank = ' ';
connectNBoard[0][0] = 0;
for(row=1; row<=numRowsInBoard; row++)
{
connectNBoard[row][0] = j;
j++;
}
for(col=1; col<=numRowsInBoard; col++)
{
connectNBoard[0][col] = i;
i++;
}
return 0;
}
There`s an error under my second for loop, in the array [cols], it says Error: expression must have pointer-to-object type. How do i fix this? Also, how would I call this function?