Why does C print my hex values incorrectly? - Stack Overflow
The placeholder %x in the format string interprets the corresponding parameter as unsigned int. To print the parameter as short, add a length modifier h to the placeholder: printf("%hx", hex); http://en.wikipedia.org/wiki/Printf_format_string#Format_place...