简体   繁体   中英

Convert hex string to little endian

I would like to convert string representation of hex for example:

"18ec1975b97174"

to little endian string. I'm familiar with python so I can achieve that with

struct.pack("<L", "18ec1975b97174")

What will be equivalent in C++? It is possible to work on string or should I convert that to numeric value first?

If you are using a machine that uses little endian, in C++ you can use the NTOH functions .

These will convert numbers in network order (big endian) to host order (litle endian).

This will only work on numeric values though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM