There are several inaccuracies in what you read. These inaccuracies were either present in the source, or maybe you remembered it incorrectly.
Firstly, a pedantic remark about one peculiar difference between C and C ++. The C language makes no guarantees regarding the relative sizes of integer types (in bytes). C only gives guarantees regarding their relative ranges. It is true that an int range is always no less than a short range, etc. However, it is formally permitted by the C standard to have sizeof(short) > sizeof(int) . In this case, the extra bits in short will serve as padding bits that are not used to represent values. Obviously, this is something that is simply permitted by the legal language in the standard, and not by those whom anyone may encounter in practice.
In C ++, on the other hand, the language specification guarantees guarantees of both relative ranges and relative sizes of types, therefore in C ++, in addition to the above relationship relations inherited from C, it is guaranteed that sizeof(int) greater than or greater than sizeof(short) .
Secondly, the C language standard guarantees a minimum range for each integer type (these guarantees are present in both C and C ++). Knowing the minimum range for a given type, you can always tell how many bits to form values ​​of this type you need to have (as the minimum number of bits). For example, it is true that the long type must have at least 32 bits to form values ​​in order to satisfy the requirements of the range. If you want to convert this to bytes, it will depend on what you mean by byte of the term. If you are talking specifically about 8-bit bytes, then indeed the long type will always consist of at least four 8-bit bytes. However, this does not mean that sizeof(long) always at least 4, since in the terminology of C / C ++ the term byte refers to char objects. char objects are not limited to 8 bits. In some implementation, it is entirely possible to have a 32-bit char type, which means that sizeof(long) in C / C ++ bytes may be legal, for example.
AnT
source share