[SOLVED] Warning: control reaches end of non void function

Issue

I’m pretty sure I have the correct return statement so i don’t know why it shows this.

/* check table full function */

bool check_table_full (char board[][SIZE])
{
    int row, col;

    for (row = 0; row < SIZE; row++) {
    for (col = 0; col < SIZE; col++) {
        if (board[row][col] != '_') {
        return true;
        }
        else {
        return false;
        }
    }
    }
}

Solution

You can try this, for example:

bool check_table_full (char board[][SIZE])
{
    int row, col;

    for (row = 0; row < SIZE; row++) {
        for (col = 0; col < SIZE; col++) {
            if (board[row][col] != '_') {
                return true;
            } else {
                return false;
            }
        }
    }
    return false; 
}

Answered By – JackySong

Answer Checked By – David Goodson (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *