2011-06-06 81 views
0

可能重复:
integer size in c depends on what?整数大小的变化?

为什么是一个整数2个字节上的16位的编译器和4个字节上的32位编译器的大小?另外,它与OS有什么关系?

printf("%d", sizeof(int));//what will be o/p on windows 32bit Turboc 32 bit architecture 
printf("%d", sizeof(int));//what will be o/p on windows 32bit visual studio 32 bit architecture 
+7

线索在你的问题 - 16位= 2字节,32位= 4字节。 – 2011-06-06 16:46:25

+0

[int的大小取决于编译器和/或处理器?](http://stackoverflow.com/questions/2331751/does-the-size-of-an-int-depend-on-the-compiler -and-或处理器) – Midas 2011-06-06 16:56:40

回答

4

16位编译器通常用于16位硬件,其中整数的自然大小为16位。 “int”类型旨在使用硬件的自然大小。

相关问题