For scanf
, you need to use %hu
since you're passing a pointer to an unsigned short
. For printf
, it's impossible to pass an unsigned short
due to default promotions (it will be promoted to int
or unsigned int
depending on whether int
has at least as many value bits as unsigned short
or not) so %d
or %u
is fine. You're free to use %hu
if you prefer, though.