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 960129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:07:58+00:00 2026-05-16T01:07:58+00:00

How can I turn this into an array? I need a board to show

  • 0

How can I turn this into an array? I need a board to show blank spaces and when the user enters it gets filled with a X or an O by another function. The current board works I would like to make it into a array[3][3] and display the contents of the array.

void showboard(char &squareOne, char &squareTwo, char &squareThree, char &squareFour, char &squareFive, char &squareSix, char &squareSeven,
    char &squareEight, char &squareNine)
{


 cout << squareOne << "|" << squareTwo << "|" << squareThree << endl
  << "-+-+-"<< endl
  << squareFour << "|" << squareFive << "|" << squareSix << endl
  << "-+-+-"<< endl
  << squareSeven << "|" << squareEight << "|" << squareNine << endl;
 }
}
  • 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-16T01:07:58+00:00Added an answer on May 16, 2026 at 1:07 am

    You can have the showboard() function accept a reference to a 3×3 array of chars. The odd-looking parameter char (&squares)[3][3] means “reference to a 3×3 array of chars named squares“.

    void showboard(char (&squares)[3][3]) 
    { 
        std::cout << squares[0][0] << "|" << squares[0][1] << "|"
             << squares[0][2] << "\n" << "-+-+-"<< "\n" 
             << squares[1][0] << "|" << squares[1][1] << "|"
             << squares[1][2] << "\n" << "-+-+-"<< "\n"
             << squares[2][0] << "|" << squares[2][1] << "|"
             << squares[2][2] << std::endl; 
    } 
    
    int main()
    {
        char s[3][3] = { {'1', '2', '3'}, {'4', '5', '6'}, {'7', '8', '9'} };
        showboard(s);
    }
    

    Alternatively, here’s an implementation that uses a for loop instead:

    void showboard(char (&squares)[3][3]) 
    { 
        for(int i = 0; i < 3; ++i)
        {
            for(int j = 0; j < 3; ++j)
            {
                std::cout << squares[i][j];
                if(j < 2) std::cout << "|";
            }
            std::cout << "\n";
            if(i < 2) std::cout << "-+-+-" << std::endl;;
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a group of strings which I need to chunk into an array.
I'm generating a multi-dimensional array in javascript that looks like this (this is the
Okay, my situation is such: I need to send the contents of a JavaScript
I have an single-dimensional array of PHP objects. Each object has two attributes, one
Total noob to anything lower-level than Java, diving into iPhone audio, and realing from
I'm trying to figure out how to get the most recent latitude and longitude
I am looking to create a dictionary with 'roll-back' capabilities in python. The dictionary
I'm a little confused about what is going on in Perl constructors. I found
I have a way that converts ulongs to bytes using binary shifts in a

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.