How to visualize bytes with C/C++

后端 未结 7 716
小蘑菇
小蘑菇 2020-12-15 10:16

I\'m working my way through some C++ training. So far so good, but I need some help reinforcing some of the concepts I am learning. My question is how do I go about visualiz

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 10:59

    Or if you have the boost lib and want to use lambda evaluations you can do it this way ...

    template
    void bytePattern( const T& object )
    {
        typedef unsigned char byte_type;
        typedef const byte_type* iterator;
    
        std::cout << "Object type:" << typeid( T ).name() << std::hex;
        std::for_each( 
            reinterpret_cast(&object), 
            reinterpret_cast(&object) + sizeof(T), 
            std::cout << constant(' ') << ll_static_cast(_1 )&&0xFF );   
        std::cout << "\n";
    }
    

提交回复
热议问题