Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bitset>
- union U
- {
- unsigned int i;
- struct
- {
- unsigned char _1;
- unsigned char _2;
- unsigned char _3;
- unsigned char _4;
- } byte;
- };
- int main()
- {
- union U u;
- u.i = 0b00001000'00001001'00001011'00001111;
- std::cout << std::bitset<8>(u.byte._1) << std::endl
- << std::bitset<8>(u.byte._2) << std::endl
- << std::bitset<8>(u.byte._3) << std::endl
- << std::bitset<8>(u.byte._4) << std::endl;
- }
Add Comment
Please, Sign In to add comment