问题
I have a struct like this:
typedef struct
{
int a;
int b;
int c;
int d;
} Hello;
then I declare it in this way:
Hello hello[6] = {};
Then I got this warning: ISO C forbids empty initializer braces, anyhow I think I need to initialize it, how to do it in the right way?
回答1:
Hello hello[6] = {{0}};
Will initialize all members of each struct to 0.
回答2:
That's not valid C. The universal zero initializer in C is {0}, not {}.
回答3:
Try something like this:-
Hello hello[6] = {{0}};
This will initialize all the members of struct to 0.
来源:https://stackoverflow.com/questions/13295872/iso-c-forbids-empty-initializer-braces-in-c