关于指针的问题 [英] Question about pointers

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

问题描述

我有以下内容:


int x = 2;


int * ip;


ip =& x;

现在我理解* ip等于2.

是否可以说* ip等于一个值和&这是

值的地址?


JS

解决方案

JS写道:

我有以下内容:

int x = 2;

int * ip;

ip =& x;

现在我理解* ip等于2.

是否可以说* ip等于一个值和&是
值的地址?



ip是一个存储变量x的内存地址的变量。


当你像这样取消引用ip:* ip,你访问x。


-

Ioannis Vranos

http://www23.brinkster.com/noicys


< blockquote>

" Ioannis Vranos" < iv*@remove.this.grad.com> skrev i en meddelelse

news:1110923535.5379@athnrd02 ...

JS写道:

我有以下内容:

int x = 2;

int * ip;

ip =& x;

现在据我了解* ip等于2.

是否可以说* ip等于一个值和&是
的地址值?



ip是一个存储变量x的内存地址的变量。

当你取消引用ip这样的时候:* ip,你访问x。




ok所以如果int x = 2,x和* ip的值都是2吗?

JS写道:

我有以下内容:

int x = 2;

int * ip; <现在正如我所理解的那样* ip等于2.

是否可以说* ip等于一个值,并且&安培;是
值的地址?




''&''是一个运营商。它不是任何地址。这是一个错字吗?


无论如何... * ip指定一个对象。该对象的原始名称是

''x''。 ''x''的值,因此* ip的值是2,因为它们都是
指定相同的对象。


V


I have the following:

int x = 2;

int *ip;

ip = &x;
now as I understand *ip equals 2.
Is it possible to say that *ip equals a value and & is the adress for that
value?

JS

解决方案

JS wrote:

I have the following:

int x = 2;

int *ip;

ip = &x;
now as I understand *ip equals 2.
Is it possible to say that *ip equals a value and & is the adress for that
value?


ip is a variable that stores the memory address of variable x.

When you dereference ip like this: *ip, you access x.

--
Ioannis Vranos

http://www23.brinkster.com/noicys



"Ioannis Vranos" <iv*@remove.this.grad.com> skrev i en meddelelse
news:1110923535.5379@athnrd02...

JS wrote:

I have the following:

int x = 2;

int *ip;

ip = &x;
now as I understand *ip equals 2.
Is it possible to say that *ip equals a value and & is the adress for that value?


ip is a variable that stores the memory address of variable x.

When you dereference ip like this: *ip, you access x.



ok so the value of x and *ip is both 2 if int x = 2 right?


JS wrote:

I have the following:

int x = 2;

int *ip;

ip = &x;
now as I understand *ip equals 2.
Is it possible to say that *ip equals a value and & is the adress for that
value?



''&'' is an operator. It is not an address of anything. Was it a typo?

Anyway... *ip designates an object. The original name of that object is
''x''. The value of ''x'' and, consequently, of *ip, is 2, since they both
designate the same object.

V


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

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