int t = 1;
In memory (for 4 byte systems) is presented in this way
---------------
| 0 | 0 | 0 | 1 |
---------------
^ ^
| byte | = 0x1 = 00000001 in binary
The binary format is
00000000 00000000 00000000 00000001
htonl()
allow to reverse the bytes if your system is a little endian system
so htonl(t)
will return:
---------------
| 1 | 0 | 0 | 0 |
---------------
^
| = 0x1 = 00000001 in binary
so the whole htonl(t)
in binary is
00000001 00000000 00000000 00000000
equal to 16777216
in decimal