ntohs

" How do i write the function specifying the processor supports little-endian or big-endian"----May be similar to ntohs?????

Are you trying to write your own htons/ntohs
functions? If you use these functions when
transferring data across a network between
machines, you don't have to worry about it
since the compiled program will do it correctly
for that hardware architecture.

The rule is:
Network byte order, as used on the
Internet, is Most Significant Byte first.

On the i80x86 the host byte order is Least Significant Byte first.