Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
signed char ch=5; while(ch = ch--) printf("%d",ch);
我读了这个。明确指出,while 语句和语句的结尾(;)是序列点。
所以我不明白为什么上面的运行无限时间并打印相同的值[5]。
你的代码应该是
signed char ch=5; while(ch--) printf("%d",ch);
因为ch--已经是一个任务。您之前重新分配ch了其先前的值ch--,ch = ch--因此ch--没有效果,并且您在每次迭代时都获得相同的值。
ch--
ch
ch = ch--
这应该适合你:
#include <stdio.h> int main() { signed char ch=5; while(ch--) printf("%d\n",ch); return 0; }