#include<stdio.h>
int main()
{
unsigned int unum = 0x80008001;
short unsigned int *snum = (short unsigned int*)&unum;
printf("%d\n", *snum);
printf("%d\n", *(snum+1));
return 0;
}
Output:
32769
32768
snum is pointing to the initial two bytes of the unum, but it's value is last two bytes of unum, and after incrementing pointer, value is the first two byte of unum.
So, It is a little endian system. But, i am not sure whether this way is right or not to know the system's type. Is it proper?