比如 :0x12345678
#include<stdio.h>
int main()
{
int val=0x11223344;
char *p=(char *)&val;
if(*p==0x44)//若低地址为低位0x44,则为小端模式
printf("Little Endian\n");
if(*p==0x11)//若低地址为高位0x11,则为大端模式
printf("Big Endian\n");
return 0;
}
#include<stdio.h>
int main()
{
int val=0x11223344;
val=((val<<8)&0xFF00FF00|(val>>8)&0xFF00FF);
val=(val<<16)|(val>>16);
printf("%x\n",val);
return 0;
}
以上
原文:https://www.cnblogs.com/qiulinzhang/p/9510627.html