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?
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
)