"Better" as in: "Beauty is in the eye of the beholder."?
Simply? another way: (uses "no"!? operations other than assignment?)
The 1988 2nd edition of "The C Programming Language" by Kernighan and Ritchie in the last two sections of Chapter 6 explains the subtleties and idiosyncrasies of this code:
uint8_t c; uint8_t string[3]; union { uint8_t bits; struct { uint8_t t7 :1; uint8_t t3456 :4; uint8_t t2 :1; uint8_t t1 :1; uint8_t t0 :1; } bi; struct { uint8_t b7 :1; uint8_t b6 :1; uint8_t b2345 :4; uint8_t b1 :1; uint8_t b0 :1; } ti; } b,d; b.bits = d.bits = c; // does b.ti.b1 = d.bi.t1; b.ti.b7 = d.bi.t7; b.ti.b0 = d.bi.t2; b.ti.b2345 = d.bi.t3456; b.ti.b6 = d.bi.t0; string[2] = b.bits;
Problems? Read the book and consider:
struct { uint8_t t0 :1; uint8_t t1 :1; uint8_t t2 :1; uint8_t t3456 :4; uint8_t t7 :1; } bi; struct { uint8_t b0 :1; uint8_t b1 :1; uint8_t b2345 :4; uint8_t b6 :1; uint8_t b7 :1; } ti;
cis an uninitialised variable so the operation will be undefined behaviour. Please post the typical Minimal, Complete, and Verifiable example that shows the code.