uint16_t
is unsigned 16-bit integer.
unsigned short int
is unsigned short integer, but the size is implementation dependent. The standard only says it’s at least 16-bit (i.e, minimum value of UINT_MAX
is 65535
). In practice, it usually is 16-bit, but you can’t take that as guaranteed.
Note:
- If you want a portable unsigned 16-bit integer, use
uint16_t
. inttypes.h
andstdint.h
are both introduced in C99. If you are using C89, define your own type.uint16_t
may not be provided in certain implementation(See reference below), butunsigned short int
is always available.
Reference: C11(ISO/IEC 9899:201x) §7.20 Integer types
For each type described herein that the implementation provides) shall declare that typedef name and define the associated macros. Conversely, for each type described herein that the implementation does not provide, shall not declare that typedef name nor shall it define the associated macros. An implementation shall provide those types described as ‘‘required’’, but need not provide any of the others (described as ‘optional’’).