typedef struct {
int width, height;
} Size;
typedef struct {
int top, left;
} Point;
typedef struct {
Size size;
Point point;
} Rectangle;
//C 没有构造函数:字段的值来自初始化列表
Rectangle rect = {{10, 10}, {5, 5}};
//或按字段名称赋值,顺序任意;省略的字段为零
Rectangle other = {.point = {.left = 5}, .size = {.width = 20, .height = 10}};
//other.point.top is 0
//{} 把每个字段置零(C23)
Rectangle empty = {};
printf("rect.size.height is %d\n", rect.size.height);
printf("other.size.width is %d\n", other.size.width);
printf("other.point.top is %d\n", other.point.top);
printf("empty.size.width is %d\n", empty.size.width);