Historically, in early C times, when processors had 8 or 16 bit wordlength,int
was identical to todays short
(16 bit). In a certain sense, int is a more abstract data type thanchar
,short
,long
orlong long
, as you cannot be sure about the bitwidth.
When definingint n;
you could translate this with "give me the best compromise of bitwidth and speed on this machine for n". Maybe in the future you should expect compilers to translateint
to be 64 bit. So when you want your variable to have 32 bits and not more, better use an explicitlong
as data type.
[Edit: #include <stdint.h>
seems to be the proper way to ensure bitwidths using the int##_t types, though it's not yet part of the standard.]