ISO C forbids empty initializer braces in C

后端 未结 3 1684
灰色年华
灰色年华 2020-12-20 23:48

I have a struct like this:

typedef struct
{
   int a;
   int b;
   int c;
   int d;
} Hello;

then I declare it in this way:



        
相关标签:
3条回答
  • 2020-12-21 00:26
    Hello hello[6] = {{0}};
    

    Will initialize all members of each struct to 0.

    0 讨论(0)
  • 2020-12-21 00:30

    That's not valid C. The universal zero initializer in C is {0}, not {}.

    0 讨论(0)
  • 2020-12-21 00:36

    Try something like this:-

      Hello hello[6] = {{0}};
    

    This will initialize all the members of struct to 0.

    0 讨论(0)
提交回复
热议问题