gpt4 book ai didi

c - 结构声明

转载 作者:太空狗 更新时间:2023-10-29 15:43:50 24 4
gpt4 key购买 nike

我见过类似这样的结构声明

typedef struct br {
int year;
int km;

} Car;

我知道我可以像这样使用那个结构

Car ford;
ford.year = 1980;
ford.km = 12

但是声明中的“br”代表什么?

最佳答案

br 称为结构标签。

创建的新类型是 struct brCar 只是 struct br 的类型别名。

这个声明

struct br ford;

等价于这个声明:

Car ford;   // ford is of type struct br

还有组合形式:

typedef struct br {
int year;
int km;
} Car;

等同于这些声明:

struct br {
int year;
int km;
};

typedef struct br Car;

关于c - 结构声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9361875/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com