1. Simple to use
+ + auto-increment operator. such as A++,++a, are equivalent to a = a+1
--the self-decrement operator. such as a--,--a, are equivalent to a = A-1
5++ is wrong, because 5 is a constant
2. The difference between ++a and a++
int a = 10;
a++; ++a;
int b = a++; int b = ++a;
++a means to perform a +1 operation on a and then assign a value to B.
a++ means that the value of a is copied first, and then a +1 operation on a, so a becomes 11, but the copied value or the 10,a++ operation is finished, and then the copied value 10 is assigned to B
The difference between--a and a--is the same.
1#include <stdio.h>2 3 intMain ()4 {5 /*6 int a = ten;7 8 A = a + 1;// One9 Ten A + = 1;// One A a++;// - - ++a;// the - a--;//A-= 1; A = A-1; - - */ - //printf ("A's value is%d\n", a); + - intb; + intA =Ten; A //B = ten +; at //B = (a++) + (++a); - - //B = one + one; -b = (++a) + (a++); - //a -one - in - //A:12 toprintf"b=%d, a=%d\n", B, a); + - return 0; the}
"Learning Notes", "C language" self-increasing self-reduction