assuming int is 4B
255 in big endian 00000000 00000000 00000000 11111111
access first 2B, 00000000 00000000 = 0
255 in little endian 11111111 00000000 00000000 00000000
access first 2B, 11111111 00000000 = this is 255 in 2B,
in little endian we have least significant byte in lower address in binary it become 0000000011111111=255
little endian variations
if insted of i=255 it was i=65535, it will result in -1
because in memory it will be 11111111 11111111 00000000 00000000
with short we will access the first 2B 11111111 11111111 which is -1 in $2’s$ compliment in 2B
and if in this case we use “unsigned short*” we will get 65535 as we are considering the first 2B as unsigned