What is the difference between "short int" and "int" in C?
In theory/by the C standard, they could be of any size as long as 16 bit <= short <= int
.
In the real world, this is how the sizes are implemented.
CPU short int
8 bit 16 16
16 bit 16 16
32 bit 16 32
64 bit 16 32
Never rely on a datatype being a given size in C. Always check the bounds in limits.h if in doubt.
They may have the same size, but it is guaranteed that int
is equal to or bigger than short int
.