There are different ways. In most environments, it will be established that short int is 16 bits and long int is 32 bits. ( long implied when you simply declare an int .) If you typedef your own type int16, you will probably end up using short int .
Another possibility is bit fields in structures. You can say something like:
struct x { int a : 16; int b : 5; ... };
And so on. If you then define:
struct x myvar; myvar.a = 54;
You can be sure that myvar.a will contain 16 bits, and myvar.b will use 5; the total size of myvar, rounding off for all bits, plus, of course, the size of any other fields.
Peter Apr 09 '09 at 15:52 2009-04-09 15:52
source share