ISO C不允许用C空初始化牙套 [英] ISO C forbids empty initializer braces in C

查看:130
本文介绍了ISO C不允许用C空初始化牙套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的结构:

  typedef结构
{
   int类型的;
   INT B:
   INT℃;
   INT D组;
} 你好;

然后我宣布它是这样的:

 你好你好[6] = {};

然后我得到了这样的警告:ISO C不允许空初始化牙套,总之我想我需要对它进行初始化,如何做到这一点的方法不对


解决方案

 你好你好[6] = {{0}};

将初始化每个结构的所有成员为0。

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?

解决方案

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

Will initialize all members of each struct to 0.

这篇关于ISO C不允许用C空初始化牙套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆