[英]ISO C forbids empty initializer braces in C
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? 然后我得到了这个警告:ISO C禁止空初始化器括号,无论如何我认为我需要初始化它,如何以正确的方式做到这一点?
那是无效的C. C中的通用零初始化器是{0}
,而不是{}
。
Hello hello[6] = {{0}};
将每个结构的所有成员初始化为0。
Try something like this:- 尝试这样的事情: -
Hello hello[6] = {{0}};
This will initialize all the members of struct to 0. 这会将struct的所有成员初始化为0。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.