c - 指针结构(C 编程)

标签 c pointers struct

我有一个我不理解的结构:

typedef struct {
    int x;
    int y;
} Position; 

typedef struct {
    int id;
    Position upper_left;
    Position lower_right;
    int priority;
} *Window_Description;

我不明白为什么struct *Window_Description前面有一个星号?它是指向结构体的指针吗?因为当我创建一些 Window_Description 时,它将是一个指针?

最佳答案

定义

typedef struct {
    int id;
    Position upper_left;
    Position lower_right;
    int priority;
} *Window_Description;

等于

struct Window_Description_Struct
{
    int id;
    Position upper_left;
    Position lower_right;
    int priority;
};

typedef struct Window_Description_Struct *Window_Description;

也就是说,它使 Window_Description 成为指向该结构的指针的别名。

关于c - 指针结构(C 编程),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28911254/

相关文章:

比较 C 中的十六进制

go - 接口(interface)内部以接口(interface)为参数的方法

c++ - 一个类型的多个 cv 分解

c++ - 为什么这个结构的大小是 3 而不是 2?

c++ - 为什么 C 和 C++ 中 ` struct T{ double x};` 的输出不同?

c - 自习室预约计划

c++ - 使用 getchar() 和 -O3 的奇怪行为

c - Windows 上使用 C 语言的输出重定向

c++ - 为什么属性不能在密封的引用类中公开

c++ - 为什么我的 C++ 指针突然不同了?