2011-06-06 80 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」類型旨在使用硬件的自然大小。

相關問題