Hey guys,
I would appreciate if you guys could help me with this code. The problem is with the "continueGame( )" function. It should return an int(0 or 1 ) and the while loop in the main runs or breaks depending on the return value. "continueGame" goes through a 8x8 grid ( which represents a game board for Othello) to see if all the spaces have been taken. Return 1 means to continue to play the game and Return 0 menas the game board is full and the game is over.
What's wrong with my code or logic? The summary of code follows. Let me know if you want the whole thing.
void main ()
{
...Some main code...
while ( continueGame( pGrid ) )
{
...Some code for the while loop...
}
...Some more main code...
}
//Function
int continueGame( char * pThisGrid[XY_MAX][XY_MAX] )
{
for (int j = 0; j < XY_MAX; j++)
{
for (int q = 0; q < XY_MAX; q++)
{
printf("\nCheck grid row:%d col:%d", j + 1, q + 1);
if ( *pThisGrid[j][q] == ' ') return 1;
}
}
return 0;
}
Thanks,
Mario
I would appreciate if you guys could help me with this code. The problem is with the "continueGame( )" function. It should return an int(0 or 1 ) and the while loop in the main runs or breaks depending on the return value. "continueGame" goes through a 8x8 grid ( which represents a game board for Othello) to see if all the spaces have been taken. Return 1 means to continue to play the game and Return 0 menas the game board is full and the game is over.
What's wrong with my code or logic? The summary of code follows. Let me know if you want the whole thing.
void main ()
{
...Some main code...
while ( continueGame( pGrid ) )
{
...Some code for the while loop...
}
...Some more main code...
}
//Function
int continueGame( char * pThisGrid[XY_MAX][XY_MAX] )
{
for (int j = 0; j < XY_MAX; j++)
{
for (int q = 0; q < XY_MAX; q++)
{
printf("\nCheck grid row:%d col:%d", j + 1, q + 1);
if ( *pThisGrid[j][q] == ' ') return 1;
}
}
return 0;
}
Thanks,
Mario