Is the size of C “int” 2 bytes or 4 bytes?

后端 未结 13 2773
不知归路
不知归路 2020-11-22 10:52

Does an Integer variable in C occupy 2 bytes or 4 bytes? What are the factors that it depends on?

Most of the textbooks say integer variables occupy 2 bytes. But whe

13条回答
  •  时光说笑
    2020-11-22 11:11

    The answer to this question depends on which platform you are using.
    But irrespective of platform, you can reliably assume the following types:

     [8-bit] signed char: -127 to 127
     [8-bit] unsigned char: 0 to 255
     [16-bit]signed short: -32767 to 32767
     [16-bit]unsigned short: 0 to 65535
     [32-bit]signed long: -2147483647 to 2147483647
     [32-bit]unsigned long: 0 to 4294967295
     [64-bit]signed long long: -9223372036854775807 to 9223372036854775807
     [64-bit]unsigned long long: 0 to 18446744073709551615
    

提交回复
热议问题