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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:55:06+00:00 2026-05-27T10:55:06+00:00

this question is regarding the syntax of an array of array of structs. I

  • 0

this question is regarding the syntax of an array of array of structs.

I have a struct that takes in two ints:

struct point
{
    int x, y;
};

I have created another struct that takes in 8 of these structs:

//Creating an Array of Array of structs
struct Arraypoint
{
    point variable[8];
};
//Not sure if this is the correct way to do it.

Now, in main, I want to declare an array variable of type Arraypoint with 8 indices, so effectively I will have 8 * 8 = 64 elements of struct point and 128 ints (64 x and 64 y).

Also, how would I access an individual element struct point from the array Arraypoint?

Okay after having declared in main lets say Arraypoint is 2.

Arraypoint arr[2];

How do I initialize the elements without having to type in arr[0].variable[0].x = ... or without using for loops.
Why can’t I do the following, it doesn’t seem to work.

Arraypoint arr[2] = {  {(x,y),(x,y),(x,y),(x,y),(x,y),(x,y),(x,y),(x,y)},
                       {(x,y),(x,y),(x,y),(x,y),(x,y),(x,y),(x,y),(x,y)}  }//xy are rand

I have used curly braces in my code, the error returned is missing braces around initializer for type point and too many initializers for type Arraypoint.

  • 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-27T10:55:07+00:00Added an answer on May 27, 2026 at 10:55 am

    got it: ideone.com/ix3hC. Arraypoint::variable has to have it’s own { } pair.

    struct point
    {
        int x, y;
    };
    #define P {0, 0}
    
    struct Arraypoint
    {
        point variable[8];
    };
    #define V { P, P, P, P, P, P, P, P} 
    #define AP { V }  //this is the pair you missed
    
    int main() {
        Arraypoint arr[2] = { AP, AP };
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is regarding getopt function in php. I need to pass two parameter
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve
I have this very straight forward question regarding Thread and Timer classes in Java
I have a question regarding the ||= statement in ruby and this is of
I have a general question regarding the syntax of throwing an object. Consider: #include
I'm trying to learn objective-c, and have a question regarding this method: - (UITableViewCell
This is a rather basic question regarding the syntax of the return statement in
I have a question regarding an SQL syntax. I have a mysql table like
Yesterday I posted this question regarding using lambdas inside of a Join() method to
Yesterday, I asked this question regarding best practices for a simple information retrieval system

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.