Variable number of bytes occupied by each type, sizeof ()

And the median operating system and compiler are related.

Available the sizeof () to get the current popular compilers are generally 32-bit or 64-bit.

  Type 16-bit 32-bit 64-bit

  char       1            1    1

  short int     2         2    2

  int          2          4    4

  long int             4        4    8

  long long int      8           8      8

  char * 2 4 8 (determined by the addressing range)

  float                 4      4      4

  double               8      8    8

 

 

 

 

int,long int,short int

The width may vary with the compiler. But there are a few principles ironclad (ANSI / ISO developed): 

sizeof(short int)<=sizeof(int)

sizeof(int)<=sizeof(long int)

short int should be at least 16 bits (2 bytes)

long int should be at least 32 bits.

* Pointer - Address

* (I.e. pointer variable): 4 bytes (32-bit machine address space . 4 bytes Similarly compiler 64) (* Change)

64-bit operating system 8 bytes.

byte

Byte is the unit of binary data. Usually eight-bit binary number. Some older computer architectures use different lengths.

B and bit

Data storage is "byte" ( Byte ) units, mostly based data transmission "bit" ( 'bit, also known as "bits") as a unit, one bit represents a 1 or 0 (i.e. binary), each 8 bit (bit, abbreviated as b) consisting of a byte (byte, abbreviated as B), a is the smallest unit of information.

 

 

 

【forward from】

https://blog.csdn.net/primeprime/article/details/80247626

https://blog.csdn.net/yimingsilence/article/details/54730438

https://wenku.baidu.com/view/f77f0d7f3d1ec5da50e2524de518964bcf84d2cf.html

https://www.cnblogs.com/GumpYan/p/5857019.html

Guess you like

Origin www.cnblogs.com/wxl845235800/p/11449565.html