How do I convert a big-endian struct to a little endian-struct?

后端 未结 8 2028
一整个雨季
一整个雨季 2020-12-08 11:03

I have a binary file that was created on a unix machine. It\'s just a bunch of records written one after another. The record is defined something like this:



        
8条回答
  •  死守一世寂寞
    2020-12-08 11:38

    It affects each member independently, not the whole struct. Also, it does not affect things like arrays. For instance, it just makes bytes in an ints stored in reverse order.

    PS. That said, there could be a machine with weird endianness. What I just said applies to most used machines (x86, ARM, PowerPC, SPARC).

提交回复
热议问题