This is C++ 101. You should be able to use a union for this:
union myConverter
{
std::uint32_t intVal;
unsigned char[4] charVal;
}
myConverter c;
c.intVal = 16000;
// c.charVal[0] - [3] now contains the unsigned hex values
union myConverter
{
std::uint32_t intVal;
unsigned char[4] charVal;
}
myConverter c;
c.intVal = 16000;
// c.charVal[0] - [3] now contains the unsigned hex values
To copy to clipboard, switch view to plain text mode
Of course, this assumes you have the same byte order on your target device. If not, you'll need to swap bytes around.
Bookmarks