0

Possible Duplicate:
integer size in c depends on what?

Why is the size of an integer 2 bytes on a 16-bit compiler and 4 bytes on a 32-bit compiler? And also, how is it related to 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
Community
  • 1
  • 1
Aragorn
  • 107
  • 1
  • 1
  • 10
  • 7
    The clue is in your question - 16-bits = 2 bytes, 32-bits = 4 bytes. –  Jun 06 '11 at 16:46
  • [Does the size of an int depend on the compiler and/or processor?](http://stackoverflow.com/questions/2331751/does-the-size-of-an-int-depend-on-the-compiler-and-or-processor) – Midas Jun 06 '11 at 16:56

1 Answers1

4

16 bit compilers are generally used for 16 bit hardware, where the natural size of an integer is 16 bits. The "int" type is intended to use the natural size of the hardware.

mah
  • 39,056
  • 9
  • 76
  • 93