D
Dharma
hi,
struct a
{
byte d;
byte buf[16];
}text;
text.buf[0] = 'A'
text.buf[1] = '\0'
text.buf[2] = 'B'
text.buf[3] = '\0'
text.buf[4] = '\0'
text.buf[5] = '\0'
main()
{
unsigned short *c = NULL;
c = (unsigned short*)&text.buf;
if(0x0000 == *c)
{
return ;
}
}
i have a structure as above. Iam type casting the byte to unsigned
short pointer.
when i do (0x0000 == *c) the first byte becomes 0x00. I found that buf
starts with odd memory address, If i make the memory Alignment to even
there is no problem,
What the low level does if memory Alignment is odd aligned and it is
unsigned short* type.
thanks,
Dharma.
struct a
{
byte d;
byte buf[16];
}text;
text.buf[0] = 'A'
text.buf[1] = '\0'
text.buf[2] = 'B'
text.buf[3] = '\0'
text.buf[4] = '\0'
text.buf[5] = '\0'
main()
{
unsigned short *c = NULL;
c = (unsigned short*)&text.buf;
if(0x0000 == *c)
{
return ;
}
}
i have a structure as above. Iam type casting the byte to unsigned
short pointer.
when i do (0x0000 == *c) the first byte becomes 0x00. I found that buf
starts with odd memory address, If i make the memory Alignment to even
there is no problem,
What the low level does if memory Alignment is odd aligned and it is
unsigned short* type.
thanks,
Dharma.