int main()
{
int count = 1;
printf("%d %d %d\n", count++, count++, count++);
count = 1;
printf("%d %d %d\n", ++count, ++count, ++count);
count = 1;
printf("%d %d %d\n", count--, count--, count--);
count = 1;
printf("%d %d %d\n", --count, --count, --count);
return 0;
}
···
$ gcc -O2 -Wall 1.c
1.c: In function ‘main’:
1.c:6:45: warning: operation on ‘count’ may be undefined [-Wsequence-point]
printf("%d %d %d\n", count++, count++, count++);
^
1.c:6:45: warning: operation on ‘count’ may be undefined [-Wsequence-point]
1.c:8:40: warning: operation on ‘count’ may be undefined [-Wsequence-point]
printf("%d %d %d\n", ++count, ++count, ++count);
^
1.c:8:40: warning: operation on ‘count’ may be undefined [-Wsequence-point]
1.c:10:45: warning: operation on ‘count’ may be undefined [-Wsequence-point]
printf("%d %d %d\n", count--, count--, count--);
^
1.c:10:45: warning: operation on ‘count’ may be undefined [-Wsequence-point]
1.c:12:40: warning: operation on ‘count’ may be undefined [-Wsequence-point]
printf("%d %d %d\n", --count, --count, --count);
^
1.c:12:40: warning: operation on ‘count’ may be undefined [-Wsequence-point]
···shell
请注意这些warning,永远不要这么写代码。当然,你可能会参加国家的计算机考试什么之类的,以前那帮命题的老师根本不懂计算机,现在的情况不知道改观了没有。