gpt4 book ai didi

c - C 中的 Typedef 和结构

转载 作者:太空狗 更新时间:2023-10-29 16:00:21 25 4
gpt4 key购买 nike

这两者有什么区别吗:

typedef struct ddwq{
int b;
}ta;

typedef struct {
int b;
}ta;

最佳答案

在前一种情况下,您可以将结构的类型引用为struct ddwqta。在后一种情况下,您只能将其引用为ta,因为该结构没有标签。

如果结构将包含指向自身的指针,则需要第一种情况,例如:

typedef struct ddwq{
int b;
struct ddwq *p;
}ta;

类型名称 ta 在结构内部不可见,因此该结构必须有一个标记名称才能引用自身。

关于c - C 中的 Typedef 和结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53212615/

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