@mateusz_s, post #29
typedef union _tPixel { struct { UBYTE Pad; UBYTE R; UBYTE G; UBYTE B; }; ULONG Value; } tPixel;
@teh_KaiN, post #31
typedef struct _RGB { UBYTE Alpha, Red, Green, Blue; } RGB; RGB data[5], yellow = { 0xff, 0xff, 0xff, 0x00 }; RGB *dest, *src = &data[0]; *dest++ = *src; *dest++ = yellow;
@Hexmage960, post #35
@teh_KaiN, post #36
Inaczej nie byłoby sensu posiadania tego typu konstrukcji w języku C.
union { struct { UBYTE r, g, b; } rgb; ULONG value; };
@michal_zukowski, post #39
@stefkos, post #41
union attrib { UWORD cost; ULONG weight; };
union attrib *attr; enum { COST, WEIGHT }; switch (type) { case COST: printf("Cena samochodu: %d\n", attr->cost); break; case WEIGHT: printf("Waga samochodu: %ld\n", attr->weight); break; }
@Hexmage960, post #37
@Hexmage960, post #42
@orila, post #45
union Color { struct RGB { UBYTE a, r, g, b; } rgb; ULONG val; }; union Color color = 0x01020304;
struct RGB *mem, value = *mem++;
@Hexmage960, post #46
@orila, post #47
union Figura { struct Prostokat { int a, b; } *p; struct Trojkat { int a, h; } *t; struct Okrag { int r; } *o; }; long pole(int typ, union Figura *f) { if (typ == PROSTOKAT) return(f->p->a * f->p->b); else if (typ == TROJKAT) return(f->t->a * f->t->h * 0.5); else if (typ == OKRAG) return(PI * f->o->r * f->o->r); return 0; }
@orila, post #49
@Hexmage960, post #48
@Artur Jarosik, post #53
@mateusz_s, post #55