Hi
I was presented with the following in a job interview and was asked to provide the output.
Please help me learn from this.
Code:
int main()
{
char buff[]={ 0x11,0x11,0x11,0x11,0x22,0x22,0x22,0x22,0x33,0x33,0x33,0x33};
char* pEnd = buff + sizeof(buff) -1;
long * plong = buff;
short* pshort = buff;
for(; plong<pEnd; plong++)
printf("0x%X\n", plong);
for(; pshort<pEnd; pshort++)
printf("0x%X\n", pshort);
return 0;
}
I now realize that short is 2 bytes and long is 4 bytes.
how does that change on other platforms?
the output is:
0xBFA29F44
0xBFA29F48
0xBFA29F4C
0xBFA29F44
0xBFA29F46
0xBFA29F48
0xBFA29F4A
0xBFA29F4C
0xBFA29F4E
I don't understand why?