即使给定的条件只是 t
,这个 for 循环仍然有效。
当它甚至不是一个有效的条件时,这怎么可能? 还有很多其他类似的异常(exception)吗?
for (t=10; t; --t) {
printf("%d",t);
}
最佳答案
How is this possible when its not even a valid condition. Are there many other exceptions like this ?
这是可能且有效的条件。
for循环中的第二个子表达式t
用于检查t
是否等于0
。它相当于
for (t=10; t != 0 ; --t) {...}
关于c - 奇怪的 for 循环条件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21631090/