# include <stdio.h> int main(void) { int a; int b; int c; int d; a = 10; b = a++; c = ++a; // d = 10 * ++a; d = 10 * a++; printf("%d, %d, %d, %d", a, b, c, d); return 0; }
編譯後的結果是13, 10, 12, 120code
a++
和 ++a
等價於a = a + 1;
b = a++;
是先將a的值賦給a再自增相似於b = a; a = a + 1;
, c = ++a;
是將a先自增再賦給c,相似於a = a + 1; c = a;