I am writing a tic-tac-toe game and I am finding it hard to make function that checks when a space is filled by either the noughts or crosses
Here is the full code (sorry a bit long):
#include <iostream>
using namespace std;
const int kingsize = 3;
char board[kingsize][kingsize];
bool p1 = false;
int p2 = -1;
char empty = 0;
/*this functions dispays the board*/
    void bord()
    {
        cout << 
"  ";
    for (int iX = 0; iX < kingsize; iX++)
        cout << "  " << iX << "  ";
    cout << endl;
    cout << "   ";
    for (int iX = 0; iX < kingsize; iX++)
        cout << "+---";
    cout << "+" << endl;
    for (int iY = 0; iY < kingsize; iY++)
    {
        cout << " " << iY << " ";
        for (int iX = 0; iX < kingsize; iX++)
            cout << "|" << board[iY][iX] << "  ";//this is the space to be filled by Os or Xs
        cout << "|" << endl;
        cout << "   ";
        for (int iX = 0; iX < kingsize; iX++)
            cout << "+---";
        cout << "+" << endl;
    }
}
/*when this function is called it will show a blank board*/
void resetBoard()
{
    for (int iY = 0; iY<kingsize; iY++)
    {
        for (int iX = 0; iX<kingsize; iX++)
        {
            board[iY][iX] = ' ';
        }
    }
}
/*this funtion is to plot the symbols in the grid based on the column and row*/
bool setboard(int iX, int iY, char cval)
{
    if (iX >= kingsize || iY >= kingsize)
        return false;
    board[iY][iX] = cval;
    return true;
}
 /*this checks if there space is filled by one of the symbols*/
bool checkbord(int x, int z, char val)
{
    bool fill = false;
    if (board[x][z] != ' ')
    {
        fill = true;
    }
    return   fill;
}
bool win(int tir)
{
    int win = 3;
    return (board[0][0] + board[0][1] + board[0][2] == win)          // row 0
        || (board[1][0] + board[1][1] + board[1][2] == win)        // chicking row 1
        || (board[2][0] + board[2][0] + board[2][2] == win)        // checking row 2
        || (board[0][0] + board[1][1] + board[2][0] == win)        // checking column 0
        || (board[0][1] + board[1][1] + board[2][1] == win)        // column 1
        || (board[0][2] + board[1][2] + board[2][2] == win)        // column 2
        || (board[0][0] + board[1][1] + board[2][2] == win)        // diagonal
        || (board[2][0] + board[1][1] + board[0][2] == win) ;       // checking diagonal
}
int main()
{
    const int r = 3, c = 3;
    char sym1 = 'X';
    char sym2 = 'O';
    char sym = 'O' || 'X';
    cout << "TIC TAC TOE" << endl;
    cout << endl;
    cout << "How To Play" << endl;
    cout << "to plot noughts and crosses you write the row number first " << endl;
    cout << "then the number of the column" << endl;
    cout << "Example :" << endl;
    cout << endl;
    resetBoard();
    bord();
    cout << endl;
    cout << "plotting row 2 column 0" << endl;
    cout << endl;
    setboard(0, 2, 'X');
    bord();
    resetBoard();
    cout << endl;
    cout << "OK LET'S PLAY!!!" << endl;
    bord();
    int y, z;
    int t=0;
    do
    {
        loop:
        cout << "first player to plot X:" << endl;
        cout << "col No." << endl;
        cin >> y;
        cout << "row No." << endl;
        cin >> z;
        t++;
        if (y > 2 || z > 2)//if the player enters numbers higher than too it will show this error message
        {
            cout << "error enter number between 0-2" << endl;
            t--;
            goto loop;
        }
        if (checkbord(y, z, sym) == 1)//if the player plots their symbol in a space that is already filled it will show this error message
        {
            cout << "spot alreay filled, please try again" << endl;
            cout << endl;
            t--;
            goto loop;
        }
        setboard(y, z, sym1);//will plot the symbol based on what the player enetered
        bord();
        loop2:
        cout << "second player plot O:" << endl;
        cout << "col No." << endl;
        cin >> y;
        cout << "row No." << endl;
        cin >> z;
        if (y > 2 || z > 2)
        {
            cout << "error enter number between 0-2" << endl;
            goto loop2;
        }
        if (checkbord(y, z, sym) == 1)
        {
            cout << "spot alreay filled" << endl;
            t--;
            goto loop2;
        }
        setboard(y, z, sym2);
        bord();
    } while (t <4);
loop3:
    cout << "first player to plot X:" << endl;
    cout << "col No." << endl;
    cin >> y;
    cout << "row No." << endl;
    cin >> z;
    t++;
    if (y > 2 || z > 2)
    {
        cout << "error enter number between 0-2" << endl;
        t--;
        goto loop3;
    }
    if (checkbord(y, z, sym) == 1)
    {
        cout << "spot alreay filled" << endl;
        t--;
        goto loop3;
    }
    setboard(y, z, sym1);
    bord();
    return 0;
}
The problem is that checkbord function works sometimes or not at all. if the player plots the noughts/cross in a place that is already taken then it will replace it and its not supposed to do that
edit: I am not getting an error but feel the problem is with the checkbord function and I am out of ideas
 
     
    