C中循环条件下的逗号运算符 [英] Comma operator in condition of loop in C
本文介绍了C中循环条件下的逗号运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdio.h>
main()
{
int i;
for(i=0; i<0, 5; i++)
printf("%d\n", i);
}
我听不懂 i< 0, 5
在 for
循环的条件下。
I am unable to understand the i<0, 5
part in the condition of the for
loop.
即使我成功了 i> 0,5
,输出没有变化。
Even if I make it i>0, 5
, there's no change in output.
这是如何工作的?
推荐答案
逗号运算符评估 i< 0
或 i> 0
并忽略。因此,条件中总是存在 5
。
Comma operator evaluates i<0
Or i>0
and ignores. Hence, it's always the 5
that's present in the condition.
所以它等效于:
for(i=0;5;i++)
这篇关于C中循环条件下的逗号运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文