I know that the most common method to test endianity programmatically is to cast to char* like this:
short temp = 0x1234;
char* tempChar = (char*)&temp;
But can it be done by casting to short* like this:
unsigned char test[2] = {1,0};
if ( *(short *)test == 1)
//Little-Endian
else
//Big-Endian
Am I right that the "test" buffer will be saved (on x86 platforms) in the memory using Little-Endian convention (from right-to-left: "0" at lower address, "1" at higher) just like in case with the "temp" var?
And more generally if I have a string: char tab[] = "abcdef"; How would it be stored in the memory? Will it be reversed like: "fedcba"?
Thx. in advance:-)
PS.
Is there any way to see how exactly the data of a program look like in the system memory?. I would like to see that byte-swap in Little-Endian in "real life".