In <3F*************@sisl.co.in> chandra sekhar nunna <n.*************@sisl.co.in> writes:
Hello All,
typedef union
{
int m_4ByteData;
char m_8bitData[4];
}data;
data conv;
conv.m_4ByteData = 1000;
I am using above union i am getting all the individual 8 bits ( 8 * 4 =
32 bits for int ). How to get the int value ( m_4ByteData) using
m_8bitData[4].
Put the stuff into m_8bitData[4] and read the value of m_4ByteData.
In theory, this invokes undefined behaviour, in practice, it works.
You may want to replace the magical constant 4 by sizeof(int) and to
use the type unsigned char for m_8bitData[4].
Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
Da*****@ifh.de