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