Hey guys and gals. I'm looking for a little help here. I am throughly lost as to how to do this program. Keep in mind I am not asking for someone to do it.... although the though is crossing my mind lol. I'm just looking for pushes in the right direction. I have to write a tic tac toe program that uses a two dimesnsional array. It's a two player game, no computer choices invovled. So I've got the program started, but I have no clue how to get it working. I'm stuck on when the first player enters the row and column number. I dont know how to convert it to placing the X in that spot on the array. Then I know I'm already lost on how to make a function that can tell if someone wins loses or ties. Any help is appricated.
1) You MUST use a function to see if someone has won. Your function MUST take as an argument the 2-dimensional character array and return a number 1 if player 1 has won or a 2 if player 2 has won.
2) You MUST use a function that takes as an argument the 2-dimensional character array and displays the contents of the board array.
This is what I got so far.
//This is a simple program to play the game Tic-Tac-Toe.
//This program will not keep score or stats.
//This is a two player game.
#include <iostream>
#include <iomanip>
using namespace std;
void displayBoard();
int main()
{
cout << "Let's play Tic Tac Toe!\n";
displayBoard();
cout << "Player One will be X's and Player Two will be O's.\n";
cout << "Each player will enter a set of coordinates for thier move.\n";
cout << "First the Row number followed by column number.\n";
cout << "Rows and columns start with 0 and end with 2\n";
cout << "starting with on the left.\n";
cout << "Player One. Please enter row number followed by column number.\n";
cin >> board[ROW][COL];
return 0;
}
void displayBoard()
{
const int ROW = 3;
const int COL = 3;
char board[ROW][COL] = {{'*', '*', '*'},
{'*', '*', '*'},
{'*', '*', '*'}};
board[0][0] = '*';
board[0][1] = '*';
board[0][2] = '*';
board[1][0] = '*';
board[1][1] = '*';
board[1][2] = '*';
board[2][0] = '*';
board[2][1] = '*';
board[2][2] = '*';
cout << board[0][0] << " | " << board[0][1] << " | " << board[0][2] << "\n";
cout << "__|___|___\n";
cout << board[1][0] << " | " << board[1][1] << " | " << board[1][2] << "\n";
cout << "__|___|___\n";
cout << board[2][0] << " | " << board[2][1] << " | " << board[2][2] <<"\n";
cout << " | | \n";
}