c++ - "unsigned :(number)" and Unions -


this question has answer here:

i dont know whats mean "unsigned :5",

for example if create these:

int a:8; unsigned b:8; 

is b integer?

and question:

in union these values:

union    { long quad;       long duble;       char byte;        struct {       unsigned :16;     unsigned :16;      unsigned :16;      unsigned :15;       unsigned bit1:1;        } bits;    }pes;   pes.quad=0x12345678; pes.duble=0xabcd; pes.byte=0xef; pes.bits.bit1=1; 

why in adress is: ef ab 00 00 cc cc cc cc

i thought ef ab 34 12 00 00 00 80

the : introduces bit field, value in struct of particular logical type actual size measured in bits. useful defining structures access individual bits of value (e.g. extract flag bits word).

for example, defining unsigned b:5; unsigned c:3; make b , c share same byte in memory, b 5 of bits , c other 3 bits.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

Kivy: Swiping (Carousel & ScreenManager) -

jdbc - Not able to establish database connection in eclipse -