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

The Archive Base Latest Questions

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

I have a question in initializing my structure array inside a structure array. for

  • 0

I have a question in initializing my structure array inside a structure array. for example if I have a code as below:

#include <stdio.h>

int main() {

typedef struct {
    int a;
    int b;
    int c;
} FIRST_T;

typedef struct {
    int x;
    int y;
    int z;
    FIRST_T *p;
} SECOND_T;

FIRST_T p1[]={{1,2,3},{3,4,5},{6,7,8}};
FIRST_T p2[]={{4,5,6},{7,8,9}};

SECOND_T my_second[]=
{
{1,2,3,p1},
{4,5,6,p2}
};

}

if I have to initialize my first array in second array intialization part itself, then how would I write my typedef of SECOND_T?
like

SECOND_T my_second[]=
{
{1,2,3,{{1,2,3},{4,5,6},{7,8,9}}},
{4,5,6,{{1,1,1},{2,2,2}}}
};

then how should be my SECOND_T?

I am sure I can’t define it as:

typedef struct {
    int x;
    int y;
    int z;
    FIRST_T p[]; //(I know its a blunder)
} SECOND_T;

Please help.

  • 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:43:04+00:00Added an answer on May 31, 2026 at 9:43 pm

    You can’t define a type with unbounded array in C, you have to specify the dimension. So you either do:

    typedef strut {
        int x;
        int y;
        int z;
        FIRST_T f[SOME_VALUE];
    } SECOND_T;
    

    and then initialize SOME_VALUE count of members always, or do it the way you did.

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

Sidebar

Related Questions

I am new to C and have a question about initializing a structure. I
I have just read a question regarding initializing multidimensional vectors ( question ) and
I have this snippet from apple sample code LazyTableImages . In the code below
In C:\Program Files\Microsoft SDKs\Windows\v7.0A\Include\WinCrypt.h , the definition for CERT_CHAIN_ENGINE_CONFIG is typedef struct _CERT_CHAIN_ENGINE_CONFIG {
I have a question today involving the StreamReader class. Specifically initializing this class using
Basicly this is what I have: Server:: Server (int port) { cout << Initializing
I have a very weird issue whilst initializing a struct with GCC 4.5.3 on
I have question regarding the SQLAlchemy. How can I add into my mapped class
I have question regarding the use of function parameters. In the past I have
I have question concerning a function I created. I would like to show the

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.