加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

指向同一对象的指针何时相等?

发布时间:2020-12-16 05:52:58 所属栏目:百科 来源:网络整理
导读:对于指向同一对象或函数的两个指针a和b,在哪种情况下C标准保证a == b?当a和b指向同一个对象时,是否有任何平台可以保持!= b? 解决方法 根据C标准(6.5.9平等操作符来自N1548委员会草案 – 2010年12月2日ISO / IEC 9899:201x) 6 Two pointers compare equal
对于指向同一对象或函数的两个指针a和b,在哪种情况下C标准保证a == b?当a和b指向同一个对象时,是否有任何平台可以保持!= b?

解决方法

根据C标准(6.5.9平等操作符来自N1548委员会草案 – 2010年12月2日ISO / IEC 9899:201x)

6 Two pointers compare equal if and only if both are null pointers,
both are pointers to the same object (including a pointer to an object
and a subobject at its beginning) or function,both are pointers to one past the last element of the same array object,or one is a pointer to one past the end of one array object and the other is a pointer to the start of a different array object that happens to immediately follow the first array object in the address space.109)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读