C言語でのエンディアンの変換
ビッグ→リトルならbe16tohとかbe32toh
リトル→ビッグならhtobe16とかhtobe32
code:c
code:c
// or
code:c
uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);
参考
Ubuntu Manpage: htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh, htobe64, htole64, 関連