Home > Software engineering >  How to convert an int value to BYTE array type, such as int=1, conversion of 0 x01
How to convert an int value to BYTE array type, such as int=1, conversion of 0 x01

Time:09-16

How to convert an int value to BYTE array type, such as int=1, conversion of 0 x01, I mainly use in serial down a machine instructions, need to transform, small white to solve

CodePudding user response:

https://blog.csdn.net/a22422931/article/details/64929815

CodePudding user response:

The union
{
Int testWord;
Char testByte [4].
} endianTest;

CodePudding user response:


Int x=0 xff01;
Reinterpret_cast & lt; LPBYTE> (& amp; X) to get a pointer, can + + access to every byte of an int value, need to pay attention to the byte order, on x86, the above code is to access 0 x01 first,
  • Related