When you use
*reinterpret_cast< unsigned int*>(data)
the compiler takes into account all 4 bytes (for a 32-bit system) near the byte that contains the value of variable 'value'.
It would be more simply to write
static_cast<unsigned int>( *data )
Last edited on
char is one byte value. Int is 4 on your PC. When you do reinterpret_cast, it treats 1-byte pointer as 4 byte one, when you dereference it you 3 higher bytes of int have unknown data.