0

I'm not entirely sure why the game doesn't exit properly when I'm supposed to win. Is there something wrong with the code?

bool won(void)
{
    // TODO
    for(int i=0; i<d; i++)
    {
        for(int j=0; j<d; j++)
        {
            if(board[i][j]!=board[d][d])
            {
                if(board[i][j]!=counter)
                    {
                        return false;
                    }
            }
        counter = counter + 1;
        }
    }
return true;
}
1
if(board[i][j]!=board[d][d])

Is board[d][d] a valid element in the array, or is d-1 the maximum index for both dimensions?

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .