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

  • SEARCH
  • Home
  • 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 7693397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:04:44+00:00 2026-05-31T21:04:44+00:00

When I run this, the numbers 1-9 don’t change to either X or O

  • 0

When I run this, the numbers 1-9 don’t change to either X or O when you pick them. They just stay as numbers. Is it a problem with trying to change the char values in a void function? Not sure how to accomplish this without using a void function.

#include <iostream>
#include <string>

using namespace std;

char vert = 0xB3;
char hori = 0xC4;
char cros = 0xC5;
char one = '1';
char two = '2';
char thr = '3';
char fou = '4';
char fiv = '5';
char six = '6';
char sev = '7';
char eig = '8';
char nin = '9';
char a;

void board()
{
    system("cls");
    cout << one << vert << two << vert << thr << endl
         << hori << cros << hori << cros << hori << endl
         << fou << vert << fiv << vert << six << endl
         << hori << cros << hori << cros << hori << endl
         << sev << vert << eig << vert << nin << endl;
}



void player1pick()
{
    cout << "First Player's turn. Please pick a box: ";
    cin >> a;
    if(a == 1)
    {
        one = 'X';
    }
    if(a == 2)
    {
        two = 'X';
    }
    if(a == 3)
    {
        thr = 'X';
    }
    if(a == 4)
    {
        fou = 'X';
    }
    if(a == 5)
    {
        fiv = 'X';
    }
    if(a == 6)
    {
        six = 'X';
    }
    if(a == 7)
    {
        sev = 'X';
    }
    if(a == 8)
    {
        eig = 'X';
    }
    if(a == 9)
    {
        nin = 'X';
    }
    board();
}

void player2pick()
{
    cout << "Second Player's Turn. Please pick a box: ";
    cin >> a;
    if(a == 1)
    {
        one = 'O';
    }
    if(a == 2)
    {
        two = 'O';
    }
    if(a == 3)
    {
        thr = 'O';
    }
    if(a == 4)
    {
        fou = 'O';
    }
    if(a == 5)
    {
        fiv = 'O';
    }
    if(a == 6)
    {
        six = 'O';
    }
    if(a == 7)
    {
        sev = 'O';
    }
    if(a == 8)
    {
        eig = 'O';
    }
    if(a == 9)
    {
        nin = 'O';
    }
    board();
}

int main()
{
    board();
    player1pick();
    player2pick();
    player1pick();
    player2pick();
    player1pick();
    player2pick();
    player1pick();
    player2pick();
    player1pick();

    return 0;
}
  • 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-31T21:04:45+00:00Added an answer on May 31, 2026 at 9:04 pm

    That’s because a is a char and you compare it with 1 which is a number. For example, when player enters fo 1 as an input, ‘1’ gets stored in a (which is 49 in ascii). And when you do comparison, e.g. if(a == 1) it basically compares ascii value of ‘1’ with 1…. so 49 == 1 which is of course false. Sou, you either have to change type of a to int, or compare char with char – a == '1'.

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

Sidebar

Related Questions

I run this piece of code on Visual C++ 2010 char c[10]; cin.get(&c[0],5); cin.get(&c[2],4);
I haven't been able to find this anywhere (or I just don't understand it).
I run this command : select * from LIST where JCODE = 8 and
I run this in localhost and it works. In the server the PHP script
When I run this query, the votes sum is 2 times what it should
Whenever I run this script the find part executes but the if statement causes
When I run this code the selected item is not visible. I've already tried
when i run this code : CONADefinitions.CONAPI_FOLDER_INFO2 FolderInfo; int iResult = 0; IntPtr Buffer
How can I run this on linux command line when my username has an
How do I run this command with subprocess? I tried: proc = subprocess.Popen( '''ECHO

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.