Ok, Big and little endians have got me confused.
The number 258, in memory, is (assuming a four-byte integer) 02010000 in hex on a little endian machine, and 00000102 on a big endian machine. Right?
Now, if that's right, is the following portable between big & little endian machines?
As in, would that output:Code:
unsigned int a = 258, x;
// Output each byte of A
for(x = 0; x < 4; x++) printf("%02X\n", (a >> (x * 8)) & 0xFF);
On both big and little endian machines? Or will it be reversed on big endian machines?Code: