如何比较指针? [英] How to compare pointers?

查看:95
本文介绍了如何比较指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有两个指针:

int *a = something;
int *b = something;

如果我想比较他们,看看他们是否指向同一个地方)work?

If I want to compare them and see if they point at the same place does (a == b) work?

推荐答案

是的,这是指针相等的定义:它们都指向同一位置href =http://en.wikipedia.org/wiki/Pointer_aliasing>指针别名)

Yes, that is the definition of pointer equality: they both point to the same location (or are pointer aliases)

这篇关于如何比较指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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