📜  是 int 在 32 位操作系统中有 2 个字节 - 无论代码示例

📅  最后修改于: 2022-03-11 14:55:50.480000             🧑  作者: Mango

代码示例1
Size of an int is more compiler dependent rather than an operating system. A 32-bit OS can have an int of 4 bytes. It's actually depended what compiler you’re using. If you're using a good-old compiler than maybe your compiler outdates to the language standard as well as not supporting the correct value of data type space.
More specifically (if you have the right compiler installed on your native system), 32-bit/64-bit processor and OS => int data type has value of 4bytes or 32bits 
16-bit processor and OS (the truth is most of today’s OS not support 16bit processors, and have a plan to run 16bit application in today’s OS? Not possible out of the box. You will need an emulator to run these programs) => int data type has value of 2byte or 16bits.
Even you have a 64-bit processor and OS installed but the compiler is not accurate than it might be show int data type as 2bytes. 
You can test the defect, by using “sizeof()” operator in C/C++ programming language