相关疑难解决方法(0)

C中静态变量的初始化

我有一个关于C中静态变量初始化的问题.我知道如果我们声明一个全局静态变量,默认情况下该值是0.例如:

static int a; //although we do not initialize it, the value of a is 0
Run Code Online (Sandbox Code Playgroud)

但是以下数据结构如何:

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

static Hello hello[3];
Run Code Online (Sandbox Code Playgroud)

是所有成员中的每一个结构hello[0],hello[1],hello[2]初始化为0

c static struct initialization

36
推荐指数
1
解决办法
5万
查看次数

标签 统计

c ×1

initialization ×1

static ×1

struct ×1