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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:21:33+00:00 2026-05-23T01:21:33+00:00

struct dataStruct { const char* s; int num; }; struct Final_struct { int n;

  • 0
struct dataStruct {     const char* s;     int num; }; 

struct Final_struct {     int n;     dataStruct a[]; }; 

Now the problem occurs when I try to initialize the Final_struct as followed:

const Final_struct Example[]= {
                                {100, { {"age", 20}, {"iq", 120}, {"bmi",26} } },
                                {100, { {"age", 36}, {"iq", 145}, {"bmi",22} }}
};

It’s a c code, and when I try to compile it gives the compiler error :

Fields of the object can not have arrrays of size 0

Any suggestions?

thank you.

  • 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-23T01:21:33+00:00Added an answer on May 23, 2026 at 1:21 am

    dataStruct a[] defines the member of the struct as an array of size 0. This is practically useless. You need to specify its size in the definition of the struct because the compiler needs to know the size of the entire struct in advance.

    Or, you can simply declare the field as dataStruct *a and then the array itself will not be contained in the struct.

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

Sidebar

Related Questions

struct elem { int i; char k; }; elem user; // compile error! struct
struct { char a; int b; } x; Why would one define a struct
struct Record { char Surname[20]; char Initial; unsigned short int Gender; //0 = male
struct TimerEvent { event Event; timeval TimeOut; static void HandleTimer(int Fd, short Event, void
struct SomeStruct { int a; int b; }; SomeStruct someFn( int init ) {
struct Div { int i; int j; }; class A { public: A(); Div&
struct struct0 { int a; }; struct struct1 { struct struct0 structure0; int b;
struct Drink { public string Name { get; private set; } public int Popularity
typedef struct { nat id; char *data; } element_struct; typedef element_struct * element; void
I have the following function: void Register(Data* _pData, uint32 _Line, const char* _pFile, ...)

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.