In C ++, the value of the prefix (unary) operator ++ and - is an lvalue , while in C it is an rvalue , that is, a temporary object that cannot be changed.
Also compare for example the assignment operator. In C ++ you can write like this
int i; int j = 10; ( i = 5 ) += j;
In C, however, such code will not be executed as the assignment operator returns an rvalue .
From standard C (6.5.3.1 Prefix increment and decrement operators)
2 The value of the operand of the prefix ++ operator is incremented. The result is the new value of the operand after incrementation. The expression ++ E is equivalent to (E + = 1). And the operators of the association.
V (6.5.16 Assignment operators)
3 An assignment operator value of the left operand. An assignment of the operand after the assignment, 111) but is not an lvalue .
From standard C ++ (5.3.2 Increment and decrement)
1 it is a bool (this use is deprecated). The operand shall be a modifiable lvalue. Completely completely completely completely completely completely The result is the updated operand; it is a bit field if it is a bit field. If it is not the type of bool, it is equivalent to the x + = 1. —End note]
As for the logical negation operator, it applies to expressions and is equivalent to the expression e == 0
From standard C (6.5.3.3 Unary arithmetic operators)
9 The operand of the logical negation operator! is contextually converted to bool (Clause 4); its value is true if it is converted. The type of the result is bool.
And from the standard C ++ (5.3.1 Unary operators)
9 The operand of the logical negation operator! is contextually converted to bool (Clause 4); its value is true if it is converted. The type of the result is bool.
In C programs, you can often find double negation applied to the expression
!!expression
This is done so that the result of the expression is exactly 0 or 1 .
int a; int c = ++++a;int a; int c = ++++a;. See How to create a minimal, self-contained and reproducible example . - PinkTux