Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6780587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:31:24+00:00 2026-05-26T16:31:24+00:00

I am making a Tic Tac Toe game and i created a function that

  • 0

I am making a Tic Tac Toe game and i created a function that inserts X or O into my array. I have run into one problem with my design. I call the function to make a move for X, but when it is the next players turn how do i make it call for O?

Is there a way after i put makeMove() i can just call somehow it to take in O turn instead of X. Because as you can see if i do X it will just always ask for X and not O. How can i make it choose to pull in X or O turn.

The problem is i need to only have one function that makes moves.

int main()
{
    while(SOME CONDITION HERE)
    {
        printBoard();
        cout << "Player X please choose a position: ";
        makeMove('X');
        cout << "Player O please choose a position: ";
        makeMove('O');
    }
}


int makeMove(char marker)
{
    int choosePosition = 0;

    cin >> choosePosition;

    ticTacBoard[choosePosition - 1] = marker;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:31:24+00:00Added an answer on May 26, 2026 at 4:31 pm

    Start with this:

    int main()
    {
        while(SOME CONDITION HERE)
        {
            printBoard();
            cout << "Player X please choose a position: ";
            makeMove('X');
            cout << "Player O please choose a position: ";
            makeMove('O');
        }
    }
    
    
    int makeMove(char marker)
    {
        int choosePosition = 0;
    
        cin >> choosePosition;
    
        ticTacBoard[choosePosition - 1] = marker;
    }
    

    Note that you’re going to want to change the SOME CONDITION HERE part, but you could quickly replace it by 1 and get the same behavior of your current script (actually, a bit better).

    But you’ll eventually want to put something there that makes sense — something that will tell the program to stop prompting the players for positions and, say, declare a winner.


    The following is just a more streamlined way of doing the same thing:

    int main()
    {
        while(SOME CONDITION HERE)
        {
            printBoard();
    
            makeMove('X');
            makeMove('O');
        }
    }
    
    
    int makeMove(char marker)
    {
        cout << "Player " << marker << " please choose a position: ";
    
        int choosePosition = 0;
    
        cin >> choosePosition;
    
        ticTacBoard[choosePosition - 1] = marker;
    
        return 0;
    }
    

    Note the added return 0 — if you don’t want to return something, you should just make makeMove return void so as not to be confusing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For learning, I'm making a tic tac toe game that's intended to be played
This is for a tic tac toe game. I need help making a check
Ok, so I'm in the process of making a Tic-Tac-Toe game to help me
i am making a noughts and crosses game (tic tac toe) and in my
I am making a complex tic tac toe program that has a variable grid
I'm working on making a two player tic-tac-toe game, and am in the phase
I am trying to make a really simple Tic-Tac-Toe game. I have stored values
I'm having a huge block trying to understand trees while making a Tic-Tac-Toe bot.
Hi I am a beginner and I am making a console tic tac toe
Making game of life I need to a have a grid that is 30x20

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.