关于C中特定结构定义的澄清

关于C中特定结构定义的澄清,c,struct,C,Struct,我在教授的幻灯片中发现了这种结构: struct point{ int x; int y; } p; p是什么意思?到目前为止,我只使用了这样的经典结构: struct point{ int x; int y; }; 定义类型为结构点的变量p 与 struct point{ int x; int y; }; struct point p; 定义类型为结构点的变量p 与 struct point{ int x

我在教授的幻灯片中发现了这种结构:

struct point{
      int x;
      int y;
} p;
p是什么意思?到目前为止,我只使用了这样的经典结构:

struct point{
      int x;
      int y;
};
定义类型为结构点的变量
p

struct point{
      int x;
      int y;
};
struct point p;
定义类型为结构点的变量
p

struct point{
      int x;
      int y;
};
struct point p;
这与使用
struct point p

当我们在中使用typedef struct p时

typedef struct point{
    int a;
    int b;
}p;
稍后我们可以使用p来声明结构指针或结构变量

创建结构指针的步骤
p*abc

创建结构变量
p xyz

这与使用
struct point p

当我们在中使用typedef struct p时

typedef struct point{
    int a;
    int b;
}p;
稍后我们可以使用p来声明结构指针或结构变量

创建结构指针的步骤
p*abc


要创建结构变量
pxyz

,它是
struct a{int x;}的组合;结构a p缩短为
结构a{intx;}p它是结构a{intx;}的组合;结构a p缩短为
结构a{intx;}p您编写的内容没有错误。但这个问题与
typedef
无关。我想强调的是,你写的是一个不同的方面,可能看起来有点相似,但不是。你写的并不是错误的。但这个问题与
typedef
无关。我想强调的是,你写的是一个不同的方面,可能看起来有点相似,但不是。