Why does a++++b show an error?

Asked 2 years ago, Updated 2 years ago, 66 views

int main ()
{
   int a = 5,b = 2;
   printf("%d",a+++++b);
   return 0;
}

error: lvalue required as increment operand

The code above cannot be executed, but if you write a++++b together, it will be executed, right? What's the difference?

int main ()
{
   int a = 5,b = 2;
   printf("%d",a++ + ++b);
   return 0;
}

c lvalue

2022-09-22 22:20

1 Answers

printf("%d",a++++b); is treated as (a++++b because of the Maximum Munch Rule.

You can only get lvalue as an operand for the posterior increment The result of the first (a++) is not lvalue An error occurs in (a++)++.


2022-09-22 22:20

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.