Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How does Vs20 13 c++ convert a 10-based plastic data (for example, 12345678) into 16-based byte type and exchange data sequences (4E6 1BC)?
How does Vs20 13 c++ convert a 10-based plastic data (for example, 12345678) into 16-based byte type and exchange data sequences (4E6 1BC)?
int RevertHex( int n)

{

//Exchange the highest byte and the lowest byte

int n 1 = 0x ff 000000 & amp; n;

int n2 = 0x000000ff & ampn;

n =(n & amp; 0x 00 ffffff)|(N2 & lt; & lt24);

n =(n & amp; 0x ffffff 00)| n 1;

//Swap the middle two bytes

n 1 = 0x 00ff 0000 & amp; n;

n2 = 0x0000ff00 & ampn;

n =(n & amp; 0x ff 00 ffff)|(N2 & lt; & lt8);

n =(n & amp; 0x ffff 00 ff)|(n 1 & gt; & gt8);

Returns n;

}

int main()

{

int n = 12345678;

printf( "n=0x%x\n ",n);

int N2 = RevertHex(n);

printf( "n2=0x%x\n ",N2);

Returns 0;

}

The hexadecimal code of 12345678 is: 0xBC6 14E (it can also be regarded as 0x 0bc 6 14E). After conversion, it is 0x4e6 1bc00.

If you don't want it at 00, you can think of another way.