So I\'m a bit of a newbie to C and I am curious to figure out why I am getting this unusual behavior.
I am reading a file 16 bits at a time and just printing them ou
The placeholder %x in the format string interprets the corresponding parameter as unsigned int.
%x
unsigned int
To print the parameter as short, add a length modifier h to the placeholder:
short
h
printf("%hx", hex);
http://en.wikipedia.org/wiki/Printf_format_string#Format_placeholders