Do any of you know where to put system("cls") in my code so that the system doesn't keep printing another board, and I just keep the same board. Thanks.
int main(void)
{
char finished; char c;
bool keep_playing = true;
cout << "Shall We Play A Game Today? \n Yes or No. (Y,N)" << endl;
string p;
cin >> p;
if (p == "Y" || p == "y")
{
system("cls");
cout << "Welcome To Tic Tac Toe \n\n" << endl;
cout << "The Human Player will be the X, during this game \n\n" << endl;
cout << "Here is how to play the game: \n\n 1) You must first enter which row you would like--from top to bottom. i.e. 1,2,3 and then press enter \n 2) Enter which column you would like, and press enter again. \n Good luck player \n\n" << endl;
while (keep_playing)
{
finished = ' ';
createboard();
do {
displayboard();
humanplayermove();
finished = checkforwinner(); /* check winner */
if (finished != ' ') break; /* if winner found...*/
computermove();
finished = checkforwinner(); /* check for winner again */
if (finished != ' ') break; /* if winner found...*/
if (checkforadraw(board)) //we don't have a winner and there are no open spaces.
{
displayboard();
cout << endl;
cout << "The Game has Ended in a Tie, surely you will want to play at least until someone wins human!!\n";
break;
}
newgameboard();
} while (finished == ' ');
if (finished == 'x')
{
cout << "You Have Defeated Me, this is impossible!!!! Let us Play Again....\n";
}
else
{
cout << "I have defeated you, I always said Machines Would become better than Humans at their own games. HAHAHA \n\n" << endl;
}
displayboard(); /* show final positions */
cout << "Would You like to go for another round? Y/N" << endl; cin >> c;
if (c == 'N' || c == 'n')
keep_playing = false;
newgameboard();
}
}
else cout << "Maybe Next Time You will be brave enough to face me." << endl;
return 0;
}