为什么 a+++++b 不起作用? [英] Why doesn't a+++++b work?
本文介绍了为什么 a+++++b 不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int main ()
{
int a = 5,b = 2;
printf("%d",a+++++b);
return 0;
}
此代码给出以下错误:
错误:需要左值作为增量操作数
error: lvalue required as increment operand
但是如果我在 a++ +
和 ++b
中放置空格,那么它工作正常.
But if I put spaces throughout a++ +
and ++b
, then it works fine.
int main ()
{
int a = 5,b = 2;
printf("%d",a++ + ++b);
return 0;
}
第一个例子中的错误是什么意思?
What does the error mean in the first example?
推荐答案
printf("%d",a+++++b);
被解释为 (a++)++ + b
根据最大蒙克规则!.
printf("%d",a+++++b);
is interpreted as (a++)++ + b
according to the Maximal Munch Rule!.
++
(后缀)不计算为 lvalue
但它要求其操作数为 lvalue
.
++
(postfix) doesn't evaluate to an lvalue
but it requires its operand to be an lvalue
.
<子>!6.4/4 说下一个预处理标记是可以构成预处理标记的最长字符序列"
这篇关于为什么 a+++++b 不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文