{
int lnibble:4;
int unibble:4;
};
union swap
{
char byte;
struct nibbles nb;
};
int main()
{
union swap sw;
int temp;
sw.byte=0x12;
printf("Before swap:%x\n",sw.byte);
temp=sw.nb.lnibble;
sw.nb.lnibble=sw.nb.unibble;
sw.nb.unibble=temp;
printf("After swap:%x",sw.byte);
}
No comments :
Post a Comment