Shouldn't an int pointer in Turbo C be of size 4 bytes?

前端 未结 5 870
长发绾君心
长发绾君心 2020-12-04 03:47

In the Turbo C compiler, the size of an int pointer is shown as 2 bytes when sizeof() operator is used. Now, if I print the address of an int variable, it comes out to be a

5条回答
  •  爱一瞬间的悲伤
    2020-12-04 04:25

    There was an era when computer were run on only DOS. At that time the booting of operating system is was real mode booting. So In Real mode operating systems the OS can use only 1MB of address space. the turboc actually made for real mode so it is called as 16 bit. the turboc doesn't know what is the RAM f your computer or what is the processor whether it is 16 bit 32 bit or 64 bit. So in turboc the pointer is always 2 bytes . .but if u change the settings under options>>compiler>>model and set it to huge. Then it goes completely upto 1 MB address space using two registers. of 2 byte and in that case pointer could be or will be 4 bytes

提交回复
热议问题