/* biglittle.c - Seeing endian issues on a little endian machine
		 and on a big endian machine.
*/

#include <stdio.h>
#include <arpa/inet.h>


int main() {
	unsigned short a = 0X0100;
	unsigned char *b = (unsigned char *)&a;
	printf("%d\n", a);
	printf("%d %d\n", b[0], b[1]);
	unsigned short c = htons(a);
	unsigned char *d = (unsigned char *)&c;
	printf("%d\n", c);
	printf("%d %d\n", d[0], d[1]);
        return 0;
}
/* It outputs on a little endian machine
256
0 1
1
1 0
   It outputs on a big endian machine
256
1 0
256
1 0
Note that within a byte bits are ordered from low to high as follows
    Most significant  Least significant
	+-+-+-+-+-+-+-+-+
	| | | | | | | | |
	+-+-+-+-+-+-+-+-+
If I look at 0x0100 I have two bytes.
In both little and big endian machines 0X01 is interpreted as the most
significant byte and 0X00 as the least significant byte. Thus in both
machines it will be printed out as 256.
As to looking at bits, in the little endian machine we will have
	00000000 00000001
and in the big endian machine we will have
	00000001 00000000
*/

