I receive a port number as 2 bytes (least significant byte first) and I want to convert it into an integer so that I can work with it. I\'ve made this:
char buf[
If you make buf into an unsigned char buf[2], you could just simplify it to;
unsigned char buf[2]
number = (buf[1]<<8)+buf[0];