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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:13:49+00:00 2026-05-13T13:13:49+00:00

Here is my struct: struct Checker { short row; short col; unsigned short number;

  • 0

Here is my struct:

struct Checker
{
  short row;
  short col;
  unsigned short number;
  short color;
};

Now, I have to also make another struct to represent a checkers board:

struct Board
{
  Checker checkers[2][13]; // Zeroth entry of 13 is not used.
  Checker *grid[8][8]; // each entry holds Null or an address
                       // of an element in the checkers array
};

If it matters, checkers[0-1] represents what side, [1-12] are unique numbers for each piece.

Anyways, I have a an 8×8 grid, that either points to NULL, or a checker piece. What i want to do is to be able to access that checker not by its unique ID (checkers[0][5] for instance), but instead by its position on the grid.

How can I access the data members in this fashion? I’l try to summarize:

Declared a Board gameBoard. Set up the grid so that I have a checkers piece at [0][0]. This would be checkers[0][1]. So instead of doing cout <<checkers[0][1].number, I’d like to be able to print the checker’s number without knowing its ID, and instead knowing that that specific checker is at [0][0]

Thanks.

  • 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-13T13:13:49+00:00Added an answer on May 13, 2026 at 1:13 pm
    cout << grid[0][0]->number;
    

    If the grid is a 2-dimensional array of pointers to Checker structs, then grid[0][0] is a pointer to the Checker at that location (0, 0). The -> syntax dereferences the pointer and then accesses the number field.

    If I am misunderstanding your question or my response fails, please let me know and I’ll happily delete. It’s late. 🙂

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

Sidebar

Ask A Question

Stats

  • Questions 299k
  • Answers 299k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This article gives a very useful code snippet to get… May 13, 2026 at 7:46 pm
  • Editorial Team
    Editorial Team added an answer I've modified Hanselman's MVC 1 example to test ASP.Net MVC… May 13, 2026 at 7:46 pm
  • Editorial Team
    Editorial Team added an answer For a non-mutating version: st = myString.substr(0, myString.size()-1); May 13, 2026 at 7:46 pm

Related Questions

I have never written a stateful IComparer<T> with a default constructor. All standard library
Ok guys, just a quick question hopefully someone can find my mistake quickly, but
I have a C function that takes a function pointer as argument, it's a
I'm writing an iterative function to search a binary tree for a certain value.
Here's a simple problem I need to solve, but it makes me feel my

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.