sizeof(ptr)=? [英] sizeof(ptr) = ?

查看:76
本文介绍了sizeof(ptr)=?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用char,short,int,long,float,double和struct

指针测试它,都返回4个字节。标准是否说明指针的大小是什么? (我没有在标准中找到它......)


-

William

http://williamxu.net9.org

I test it with char, short, int, long, float, double and struct
pointers, all return 4 bytes. Does the standard say anything about
sizeof a pointer? (I didn''t find it in the standard...)

--
William

http://williamxu.net9.org

推荐答案

William Xu写道:
William Xu wrote:

我用char,short,int,long,float,double和struct测试它

指针,全部返回4个字节。标准是否说明指针的大小是什么? (我没有在标准中找到它...)
I test it with char, short, int, long, float, double and struct
pointers, all return 4 bytes. Does the standard say anything about
sizeof a pointer? (I didn''t find it in the standard...)



不,它是特定于实现的。


-

Ian Collins。

No, it is implementation specific.

--
Ian Collins.


William Xu写道:
William Xu wrote:

我测试它有char,short,int,long,float,double和struct

指针,都返回4个字节。标准是否说明指针的大小是什么? (我没有在标准中找到它......)
I test it with char, short, int, long, float, double and struct
pointers, all return 4 bytes. Does the standard say anything about
sizeof a pointer? (I didn''t find it in the standard...)



它的实现定义。

例如 32位机器上的
,sizeof(ptr)可能是32

和64位机器它返回64.




-

C常见问题: http://c-faq.com/

it''s implementation defined.
e.g

on 32-bit machine, sizeof(ptr) may be 32
and 64-bit machine it returns 64.

Road
--
C FAQ: http://c-faq.com/


William Xu写道:
William Xu wrote:

I用char,short,int,long,float,double和struct

指针测试它,都返回4个字节。标准是否说明指针的大小是什么? (我没有在标准中找到它...)
I test it with char, short, int, long, float, double and struct
pointers, all return 4 bytes. Does the standard say anything about
sizeof a pointer? (I didn''t find it in the standard...)



No.它表示void *类型的指针必须能够保存任何

指针值,但没有具体说明

指针的大小。不同类型的指针可以是相同或不同的

尺寸。

No. It says that a pointer of type void * must be capable of holding any
pointer value, but nothing specific is said about the sizes of
pointers. Pointers to different types could be of the same or different
sizes.


这篇关于sizeof(ptr)=?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆