C++ - 大端转小端函数
用于多字节的大端转小端
//大端转小端 void endianSwap(uint8_t *pData, int startIndex, int length) { int i, cnt, end, start; cnt = length / 2; start = startIndex; end = startIndex + length - 1; uint8_t tmp; for (i = 0; i < cnt; i++) { tmp = pData[start + i]; pData[start + i] = pData[end - i]; pData[end - i] = tmp; } } void use_endianSwap(uint8_t *pData) { for (int i = 0; i < 4; i += 4) { endianSwap(pData, i, 4); } }
博客园文作者:Citrusliu
博文地址:https://www.cnblogs.com/citrus