int RevertHex( int n)
{
//交换最高字节和最低字节
int n1= 0xff000000 & n;
int n2= 0x000000ff & n;
n = (n&0x00ffffff)|(n2<<24);
n = (n&0xffffff00)|n1;
//交换中间两字节
n1 = 0x00ff0000 & n;
n2 = 0x0000ff00 & n;
n = (n&0xff00ffff) | (n2<<8);
n = (n&0xffff00ff) | (n1>>8);
return n;
}
int main()
{
int n = 12345678;
printf( "n=0x%x\n", n);
int n2 = RevertHex(n);
printf( "n2=0x%x\n", n2);
return 0;
}
12345678 的十六进制为:0xBC614E(也可看作0x00BC614E) 转化后为:0x4e61bc00
如果00不要可以再想办法。
欢迎分享,转载请注明来源:品搜搜测评网