#include <stdio.h>
typedef struct {
struct { // anonymous struct
float x, y;
} pos;
struct { // anonymous struct
float r, g, b;
} color;
} Vertex;
int main() {
Vertex vr;
printf("size: %zu\n", sizeof(vr));
vr.pos.x = 100.0f;
vr.pos.y = 200.0f;
printf("vr.pos.x: %.2f\n", vr.pos.x);
printf("vr.pos.y: %.2f\n", vr.pos.y);
vr.color.r = 60.0f;
vr.color.g = 255.0f;
vr.color.b = 80.0f;
printf("vr.color.r: %.2f\n", vr.color.r);
printf("vr.color.g: %.2f\n", vr.color.g);
printf("vr.color.b: %.2f\n", vr.color.b);
return 0;
}
/*
run:
size: 20
vr.pos.x: 100.00
vr.pos.y: 200.00
vr.color.r: 60.00
vr.color.g: 255.00
vr.color.b: 80.00
*/