Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

84
Views
Initialize an array of an array of structs

I am trying to initialize an array of an array of structs in C. Is this possible?

Example to illustrate the issue (does not compile):

typedef struct myStruct
{
    int row;
    int cols;
} myStruct;

myStruct dataSets[][] =
{
    myStruct dataSet1[]
    {
        {0,1},
        {0,2},
        {0,3},
    },

    myStruct dataSet2[]
    {
        {1,1},
        {1,2},
        {1,3},
    }
};
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

When initializing a multidimensional array, only the outer array dimension may be omitted. You also don't need to specify the type for nested initializers as the type is implied from context:

myStruct dataSets[][3] =
{
    {
        {0,1},
        {0,2},
        {0,3},
    },
    {
        {1,1},
        {1,2},
        {1,3},
    }
};
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!