-2

I'm creating a code for Tic Tac Toe, trying to use a void function for it to try again if the slot that they choose is full up. This is my code from boardInput() & tryAgain():

    void boardInput()
    {
        int a;
        cout << "Round: " << iRound << endl;

        cout << "Row: ";
        cin >> a;
        int b;
        cout << "Column: ";
        cin >> b;

        if (a == 1 && b == 1)
        { 
            if (chGrid[0][0] == '-')
                chGrid[0][0] = chPlayer;
            else
            {
                tryAgain();
            }
        }
    }

void tryAgain()
{
    system("cls");
    displayBoard();
    cout << "ERROR! Try again!" << endl;
    boardInput();
}

I've tried to move the void around and it still comes to the same error. Could anyone help me?

Mahi
  • 15
  • 6
  • 4
    In C++ symbols must be *declared* before they are used. Do some research about *forward declarations*. And beware of possible to deep recursion, consider a solution using loops instead. – Some programmer dude Nov 27 '17 at 16:25

1 Answers1

0

void tryAgain() is not declared above void boardInput(). Your prototype will be

void tryAgain(); void boardInput();

You need to put all prototype function on the top of your file. If there is a lot of prototype, you can put them in a header file that will be include on the top of the .c file (#include myfyle.h)

P1t_
  • 165
  • 1
  • 8