关于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
无关。我想强调的是,你写的是一个不同的方面,可能看起来有点相似,但不是。