gpt4 book ai didi

c - typedef 结构作为指针?

转载 作者:行者123 更新时间:2023-11-30 16:26:46 26 4
gpt4 key购买 nike

我有一个关于 typedef struct 的问题,我相信我知道答案,但希望得到一些澄清。

假设我有:

typedef struct Scanner{
//information
}myScanner;

这与以下含义相同吗:

typedef struct Scanner *myScanner; 
struct Scanner {
//information
};

最佳答案

如果对两个 typedef 定义使用相同的格式,将很容易看出差异:

typedef struct Scanner myScanner;

对比

typedef struct Scanner *myScanner;

使用typedef定义类型别名与声明变量非常相似。对于 typedef 来说,星号意味着“定义为指针”,就像变量一样。

关于c - typedef 结构作为指针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52969972/

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