Guest User

Untitled

a guest
Dec 7th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <bitset>
  3.  
  4. union U
  5. {
  6. unsigned int i;
  7. struct
  8. {
  9. unsigned char _1;
  10. unsigned char _2;
  11. unsigned char _3;
  12. unsigned char _4;
  13. } byte;
  14. };
  15.  
  16. int main()
  17. {
  18. union U u;
  19. u.i = 0b00001000'00001001'00001011'00001111;
  20. std::cout << std::bitset<8>(u.byte._1) << std::endl
  21. << std::bitset<8>(u.byte._2) << std::endl
  22. << std::bitset<8>(u.byte._3) << std::endl
  23. << std::bitset<8>(u.byte._4) << std::endl;
  24. }
Add Comment
Please, Sign In to add comment