Ok I have a Tic Tac Toe game, and I just changed the structure of it and it won't alternate between players. It switches in the function, but the player doesn't change when the loop starts over. Here are the three functions that will be needed:
Code:void GameMain() { GameInit(); do { ShowGrid(); GetInput(player); Write2Grid(choice, player); }while (true); } char GetInput(int player) { switch(player) { case 1: cout << "It's X's turn. " << endl; cin >> choice; break; case 2: cout << "It's O's turn. " << endl; cin >> choice; break; default: cout << "Error! Program will now terminate."; getch(); exit(0); break; } return choice; } void Write2Grid(int choice, int player) { if (choice < 1 || choice > 9) { cout << "Select a number that's on the board." << endl; getch(); } char xo; xo = (player == 1) ? 'X' : 'O'; int c = 2 - (choice-1)/3; int d = (choice-1)%3; if ( (Grid[c][d] == 'X') || (Grid[c][d] == 'O') ) { cout << "Spot has already been taken! Select another spot." << endl; getch(); } else { Grid[c][d] = xo; if (CheckWin() == true) { system("cls"); ShowGrid(); cout << "Congradulations, "<< xo << " has won!" << endl; getch(); PlayAgain(); } else { player = (player == 1) ? 2 : 1; } } }