
#include<stdio.h>
/*
* 结构体嵌套:结构体允许再内部定义另外一个结构体
* 结构体数组:数组的每个成员都是结构体
*/
//子弹结构体 坐标 速度 harm
struct
{
int x;
int y;
};
struct Bullet
{
struct
{
int x;
int y;
}pos;
//struct Point pos; //嵌套了
int dx; //vx xSpeed
int dy; //vy ySpeed
int harm; //伤害
};
int main()
{
struct Bullet blet;
blet.pos.x;
blet.pos.y;
blet.dx;
return 0;
}
这篇博客介绍了C语言中结构体的嵌套使用和结构体数组的概念。通过示例展示了如何定义一个包含坐标和速度信息的子弹结构体,并在主函数中初始化结构体数组成员。内容涉及结构体的定义、初始化以及成员访问。

4万+

被折叠的 条评论
为什么被折叠?



