Why doesn't a+++++b work?

前端 未结 9 1125
悲&欢浪女
悲&欢浪女 2020-11-22 06:26
int main ()
{
   int a = 5,b = 2;
   printf(\"%d\",a+++++b);
   return 0;
}

This code gives the following error:

error: lval

9条回答
  •  失恋的感觉
    2020-11-22 07:30

    I think the compiler sees it as

    c = ((a++)++)+b

    ++ has to have as an operand a value that can be modified. a is a value that can be modified. a++ however is an 'rvalue', it cannot be modified.

    By the way the error I see on GCC C is the same, but differently-worded: lvalue required as increment operand.

提交回复
热议问题