Saturday, July 21, 2012

difference between short int and int (int vs short int) ?

Actually the size of int is fully dependent on machine and compiler. But c requires to maintains the following relationship:  sizeof(short int)<=sizeof(int)<=sizeof(long int)<sizeof(long long int).
For e.g. in 32 bits operating system sizeof(short int)=2 bytes, sizeof(int)=2bytes, sizeof(long int)=4bytes, sizeof(long long int)=4bytes.
but in case of 64 bits operating system sizeof(long long int)=8bytes.
So the bottom line is that size of integer is totally dependent on the machines and compilers.

No comments:

Post a Comment