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

前端 未结 9 1005
悲&欢浪女
悲&欢浪女 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:24

    Your compiler desperately tries to parse a+++++b, and interprets it as (a++)++ +b. Now, the result of the post-increment (a++) is not an lvalue, i.e. it can't be post-incremented again.

    Please don't ever write such code in production quality programs. Think about the poor fellow coming after you who needs to interpret your code.

提交回复
热议问题