ISO C forbids empty initializer latches in C

I have a structure like this:

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

then I declare it as follows:

 Hello hello[6] = {}; 

Then I received this warning: ISO C forbids empty initializer strings, anyway, it seems to me that I need to initialize it, how to do it right?

+3
source share
3 answers
 Hello hello[6] = {{0}}; 

Initializes all members of each structure to 0.

+6
source

This is not true C. The universal null initializer in C is {0} , not {} .

+6
source

Try something like this: -

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

This will initialize all members of the structure to 0.

+3
source

Source: https://habr.com/ru/post/1496240/


All Articles