简体   繁体   中英

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?

那是无效的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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM