Another type we haven't met is short int. A short int has the same guarantees as a plain int: it will hold integers in at least the range +-32,767. The difference between short int and plain int is that short int might be smaller. Remember, the definitions of both these types (like all C types) is that they have at least the specified range. On some machines, plain int will hold numbers greater than 32,767. (On 32-bit machines, for example, it's common for plain int to be 32 bits, and to hold +-2,147,483,647. Yes, this is all the way up to the minimum range for a long int.) You might use a short int when you had a lot of them and were worried about saving memory. If you had a large array of integers all less than 32,768, or a large number of structures with one or more members holding integers all less than 32,768, you might declare the array or the structure members as short int, to avoid devoting 4 bytes to each of them on 32-bit machines.
Read sequentially: prev next up top
This page by Steve Summit // Copyright 1996-1999 // mail feedback