size of long int and int in C showing 4 bytes

This question already has an answer here:

  • What does the C++ standard state the size of int, long type to be? 24 answers

  • the specs say that
    sizeof(int) <= sizeof(long) but at least 32bit for long and 16bit for int .

    http://www.cplusplus.com/doc/tutorial/variables/

    (prefix singned or unsigned make no difference for the space they need)

    if you want to use a specified bit width i recommend to use int32_t , uint64_t , etc.


    According to documentation on the size of datatypes, your results are correct.

    long int (both signed and unsigned) and int (both signed and unsigned) are both 32 bits on a 64-bit Windows installation, so they would show up as 4 bytes.

    链接地址: http://www.djcxy.com/p/40396.html

    上一篇: c ++数字类型的最大值

    下一篇: C中long int和int的大小显示4个字节