size of long int and int in C showing 4 bytes
This question already has an answer here:
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.
上一篇: c ++数字类型的最大值