.- .

颠倒整数中的字节顺序。

语法

unsigned short _byteswap_ushort ( unsigned short val );
unsigned long _byteswap_ulong ( unsigned long val );
unsigned __int64 _byteswap_uint64 ( unsigned __int64 val );

参数

val
要颠倒字节顺序的整数。

要求

例程 必需的标头
_byteswap_ushort <stdlib.h>
_byteswap_ulong <stdlib.h>
_byteswap_uint64 <stdlib.h>

有关兼容性的详细信息,请参阅 兼容性

示例

// crt_byteswap.c
#include <stdlib.h>

int main()
{
   unsigned __int64 u64 = 0x0102030405060708;
   unsigned long ul = 0x01020304;

   printf("byteswap of %I64x = %I64x\n", u64, _byteswap_uint64(u64));
   printf("byteswap of %Ix = %Ix", ul, _byteswap_ulong(ul));
}
byteswap of 0102030405060708 = 0807060504030201
byteswap of 01020304 = 04030201

另请参阅

按类别分的通用 C 运行时例程