try this, slightly more maintainable.
Code:
#include <iostream.h>
#include <stdlib.h>
#include <windows.h>
const short REELS=3, SYMBOLS=3;
void ClearBoard(int [REELS][SYMBOLS]);
void ShowBoard(int [REELS][SYMBOLS]);
void StartGame(int [REELS][SYMBOLS]);
int main()
{
int Tic[3][3];
cout << "Welcome To Tic Tac Toe !" << endl;
cout << "Menu:\n\n";
cout << "1. Start New Tic Tac Toe Game" << endl;
cout << "2. Exit Tic Tac Toe" << endl << endl;
cout << "Your choice: ";
int choice;
cin >> choice;
switch(choice)
{
case 1: StartGame(Tic);
break;
case 2:
cout << "Thanks For Playing Tic Tac Toe!" << endl;
cout << "Programmed By Dark-Dragon ([email protected])" << endl;
system("pause");
break;
default:
cout << "Error Input! Quitting...";
system("cls");
system("pause");
}
return 0;
}
void ClearBoard(int Tic[REELS][SYMBOLS])
{
for(int i=0; i < REELS; i++)
for(int j=0; j < SYMBOLS; j++)
Tic[i][j]=0;
}
void ShowBoard(int Tic[REELS][SYMBOLS])
{
cout << Tic[0][0] << Tic[0][1] << Tic[0][2] << endl;
cout << Tic[1][0] << Tic[1][1] << Tic[1][2] << endl;
cout << Tic[2][0] << Tic[2][1] << Tic[2][2] << "\n\n\n";
}
void StartGame(int Tic[REELS][SYMBOLS])
{
char name1[50];
char name2[50];
cout << "\n\nStarting A New Game!" << endl;
cout << "Player1, please input your name: ";
cin >> name1;
cout << "Player2, please input your name: ";
cin >> name2;
cout << "\nStarting battle: " << name1 << " vs. " << name2 << endl;
ClearBoard(Tic);
ShowBoard(Tic);
int i=0, col, row, x;
do
{
cout << "Turn: " << name1 << endl;
cout << name1 << ", please input your move: ";
cin >> col;
cin >> row;
Tic[col-1][row-1] = 1;
ShowBoard(Tic);
cout << "Turn: " << name2 << endl;
cout << name2 << ", please input your move: ";
cin >> col;
cin >> row;
Tic[col-1][row-1] = 1;
}while(x != 0);
}