c++ - 为什么指针变量 的sizeof()打印出来的都是 4;
PHP中文网
PHP中文网 2017-04-17 14:32:34
0
5
1288
PHP中文网
PHP中文网

认证高级PHP讲师

reply all(5)
阿神

The number of bytes occupied by the pointer is related to the number of processor bits. A 32-bit processor is 4 bytes. Although you may have a 64-bit processor, it depends on whether you are a 64-bit program, so as long as int is 4 bytes, then the pointer is still 4 bytes

Peter_Zhu

The pointer saves an address, not any other data. . . So the size is fixed

左手右手慢动作

The pointer is 4 bytes in 32-bit and 8 bytes in 64-bit.
4 bytes can represent up to 4G.

The pointer is like a house number. Whether it is a large villa or a small store, there is no difference in the house number.
It only represents an address and has nothing to do with the content of the address

阿神

The pointer points to the address. As a 32-bit machine, the address is 4*8=32 bits, that is, the pointer size under a 32-bit machine is 4;
If it is a 64-bit machine, then the address It is 8*8=64 bits, that is, the pointer size under the 64-bit machine is 8;

左手右手慢动作

As mentioned above, the pointer is like a house number. No matter how large a house it is pointing to, the house number always has 4 digits.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template