dealing with endianness in c++

后端 未结 5 1506
走了就别回头了
走了就别回头了 2020-12-17 05:44

I am working on translating a system from python to c++. I need to be able to perform actions in c++ that are generally performed by using Python\'s struct.unpack

5条回答
  •  星月不相逢
    2020-12-17 06:30

    Unpack the string one byte at a time.

    unsigned char *str;
    unsigned int result;
    
    result =  *str++ << 24;
    result |= *str++ << 16;
    result |= *str++ << 8;
    result |= *str++;
    

提交回复
热议问题