++的结果不是左值? [英] The result of ++ is not an lvalue?

查看:72
本文介绍了++的结果不是左值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

K& R2,均为A7.3.4后缀增量和secA.7.4.1前缀
增量运算符表示结果不是左值。

这是对的吗?我没有看到这些观点的勘误。如果低于p ++

或++ p不是左值,则* p ++或* ++ p是语法错误。


当它谈到一元运算符,为什么secA7.4收集

前缀和后缀增量运算符在一起?


int main(void)

{

char a [10] = {0},* p = a;


/ * a [0] =''一个''; a [1] =''b''; * /

/ * * p =''a''; *(p + 1)=''b''; * /

/ * * p =''a''; * p ++ =''b''; P--; * /

* p =''a''; * ++ p =''b''; p--;

返回0;

}

K&R2, both sec A7.3.4 Postfix Incrementation and secA.7.4.1 Prefix
Incrementation Operators say that "The result is not an lvalue". Is
this correct? I don''t see an errata on these points. If below the p++
or ++p is not an lvalue, then *p++ or *++p is a syntax error.

When it talks about Unary Operators, why doesn''t the secA7.4 collect
both the prefix and postfix incrementation operators together?

int main(void)
{
char a[10] = {0}, *p = a;

/* a[0] = ''a''; a[1] = ''b''; */
/* *p = ''a''; *(p+1) = ''b''; */
/* *p = ''a''; *p++ = ''b''; p--; */
*p = ''a''; *++p = ''b''; p--;
return 0;
}

推荐答案

lovecreatesbea ... @ gmail.com写道:
lovecreatesbea...@gmail.com wrote:

K& R2,均为A7.3.4后缀增量和secA.7.4.1前缀

增量运算符表示结果不是左值。

这是对的吗?
K&R2, both sec A7.3.4 Postfix Incrementation and secA.7.4.1 Prefix
Incrementation Operators say that "The result is not an lvalue". Is
this correct?



是的。结果是一个值,并且没有指定它的位置。

左值必须有一个与之相关的位置。

Yes. The result is a value, and specifies nothing about where it is.
An lvalue must have a location associated with it.


我不要在这些方面看不到勘误。
I don''t see an errata on these points.



勘误表是为错误而保留的。为什么

会有错误的错误?

Errata are reserved for errors. Why should there be an erratum for
something not in error?


如果低于p ++

或+ + p不是左值,那么* p ++或* ++ p是语法错误。
If below the p++
or ++p is not an lvalue, then *p++ or *++p is a syntax error.



真的吗?为什么要声明这个?

当p是指针时,p ++或++ p的结果是一个指针值,当然可以取消引用
。为什么你会认为只有左撇子

可以被解除引用? ''*''间接运算符应用于
表达式,而不仅仅是左值。

Really? Why would you claim that?
When p is a pointer, the result of p++ or ++p is a pointer value which
can of course be dereferenced. Why would you think that only lvalues
can be dereferenced? The ''*'' indirection operator is applied to
expressions, not just lvalues.


当谈到一元运算符时,为什么不'secA7.4收集

前缀和后缀增量运算符在一起?
When it talks about Unary Operators, why doesn''t the secA7.4 collect
both the prefix and postfix incrementation operators together?



演示文稿的选择取决于作者。我们不介意

读者也不负责他们的选择。问问他们。我甚至不确定

你的问题意味着什么。当然在K& R1(A.7.2一元运算符)中,

++左值,左值 - ,左值+和左值 - 大约接近每个

其他在物理上可能。

The choice of presentation is up to the authors. We are not mind
readers nor responsible for their choices. Ask them. I''m not even sure
what your question means. Certainly in K&R1 (A.7.2 Unary Operators) the
++lvalue, lvalue--, lvalue++, and lvalue-- are about as close to each
other as is physically possible.


>

int main(无效)

{

char a [10] = {0},* p = a;


/ * a [0] =''a''; a [1] =''b''; * /

/ * * p =''a''; *(p + 1)=''b''; * /

/ * * p =''a''; * p ++ =''b''; P--; * /

* p =''a''; * ++ p =''b''; p--;

返回0;

}
>
int main(void)
{
char a[10] = {0}, *p = a;

/* a[0] = ''a''; a[1] = ''b''; */
/* *p = ''a''; *(p+1) = ''b''; */
/* *p = ''a''; *p++ = ''b''; p--; */
*p = ''a''; *++p = ''b''; p--;
return 0;
}


" lovecreatesbea ... @ gmail.com" < lo *************** @ gmail.comwrites:
"lovecreatesbea...@gmail.com" <lo***************@gmail.comwrites:

K& R2,均为A7.3.4后缀增量和secA.7.4.1前缀

增量运算符表示结果不是左值。

这是对的吗?
K&R2, both sec A7.3.4 Postfix Incrementation and secA.7.4.1 Prefix
Incrementation Operators say that "The result is not an lvalue". Is
this correct?



绝对。

Absolutely.


我没有看到这些点的勘误。如果低于p ++

或++ p不是左值,则* p ++或* ++ p是语法错误。
I don''t see an errata on these points. If below the p++
or ++p is not an lvalue, then *p++ or *++p is a syntax error.



否,一元的操作数*操作员不需要是一个价值的b $ b值;它只需要一个指针值。


-

Keith Thompson(The_Other_Keith) ks *** @ mib.org < http://www.ghoti.net/~kst>

圣地亚哥超级计算机中心< *< http:/ /users.sdsc.edu/~kst>

我们必须做点什么。这是事情。因此,我们必须这样做。

- Antony Jay和Jonathan Lynn,是部长

No, the operand of the unary "*" operator doesn''t need to be an
lvalue; it just needs to be a pointer value.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


5月19日,10日:48 pm,lovecreatesbea ... @ gmail.com

< lovecreatesbea ... @ gmail.comwrote:
On May 19, 10:48 pm, "lovecreatesbea...@gmail.com"
<lovecreatesbea...@gmail.comwrote:

K& R2,均为A7.3.4后缀增量和secA.7.4.1前缀

这是对的吗?我没有看到这些观点的勘误。如果低于p ++
K&R2, both sec A7.3.4 Postfix Incrementation and secA.7.4.1 Prefix
Incrementation Operators say that "The result is not an lvalue". Is
this correct? I don''t see an errata on these points. If below the p++



是,结果不是左值。

Yes, the result is not an lvalue.


或++ p是不是左值,那么* p ++或* ++ p是语法错误。
or ++p is not an lvalue, then *p++ or *++p is a syntax error.



编号那个(p ++)不是左值意味着没有

改变的方式(p ++),并不意味着(p ++)不能被解除引用。


让我们看看p = 1,( p ++)也是1.这个''1'不能改变

,因为这个''1'不会改变任何变量

有左值。你不能做(p ++)= 2,例如。

No. That (p++) isn''t an lvalue means that there is no way to
change (p++), and doesn''t mean (p++) cannot be dereferenced.

Let''s see p = 1, (p++) is also 1. This ''1'' cannot be changed
in the way that any variable is changed because this ''1'' does not
have lvalue. You can''t do (p++) = 2, for example.


这篇关于++的结果不是左值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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