Interview Question
Country: United States
int i;
int testInt=0xff;
unsigned char *testChar;
testChar = &testInt;
for (i=1; i<=4; i++)
{
printf("value in byte %d is %d\n", i, *testChar);
testChar++;
}
This might not be as clear. If you use int testInt=0xffee;
Least significant byte = ee
Most significant byte=ff
Now if you print the value at testchar pointer the output, if the machine is not sparc, would be-
value in byte 1 is 238
value in byte 2 is 255
Suggesting that the machine follows little endian format.
- Anonymous February 13, 2014