i have the next code:
what i'm trying to do is to split the 2 bytes of unsigned short int into two single chars. the thing is, *(&port_n+1) does not give me the right value.Code:unsigned short int port_n; port_n = htons(6667); printf("%x\n%x", (char) port_n, (char) *(&port_n+1));
int is 2 bytes long, what am i doing wrong?
thank you.