Hi I'm kind of new to C++ and I have an assignment to create a Tic Tak Toe game. I have most of the program done. All I need is to update the board and to have the winning function check if there is a winner and if there is one to say who it was. Here is a copy of my code.
#include <iostream>
#include<cstdio>
using namespace std;
int main ()
{
//Define adn initalize veriables
int iTurnCount = 0, iWinner = 0;
int iSpace; //THe user selected move, legal values 1-9
bool bTurn = true; //If ture X turn if fales O turn
char caBoard [SIZE] [SIZE];
printf("XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\n");
printf(" Tic Tak Toe \n");
printf("XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO\n");
for (int iRow = 0; iRow < SIZE; iRow++)
{
for (int iCol = 0; iCol < SIZE; iCol++)
{
caBoard[iRow][iCol] = '%';
}
}
// main game loop
do {
//display board
displayBoard (caBoard, bTurn);
//Get user input
cin >> iSpace;
//Validate user input
while(validate(caBoard, bTurn, iSpace))
{
printf("ERROR, must a correct choice\n");
displayBoard (caBoard, bTurn);
cin >> iSpace;
}
//Update board/game
update(caBoard, bTurn, iSpace);
//Determine if there is a winner
iWinner = winner(caBoard, bTurn);//1 X win 2 O win 3 cat
// Change player
bTurn = !bTurn;
//End main loop
}while (iWinner == 0);
return 0;
}