逗号操作员在河套Conditon用C [英] Comma Operator in Conditon of Loop in C

查看:106
本文介绍了逗号操作员在河套Conditon用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

    #include<stdio.h>
    main()
    {
        int i;
        for(i=0;i<0,5;i++)
        printf("%d\n",i);
    }

我只是想为I&LT; 0,5的解释。在for循环的条件

I just want the explanation for "i<0,5" in the condition of for loop.

即使我让I> 0,5,我们得到相同的输出。

Even if I make it "i>0,5", we get same output.

有人能xplain我怎么样条件的工作。 (逗号分隔符的条件,我已经搜查 http://en.wikipedia.org/wiki/Comma_o​​perator ,但没有帮助全部)

Can someone xplain me how this kind of condition work. (Conditions with comma operator, I already searched http://en.wikipedia.org/wiki/Comma_operator but no help at all)

推荐答案

逗号运算我℃的 I&GT; 0 和忽略。因此,它总是在 5 这是在条件present。

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++)

这篇关于逗号操作员在河套Conditon用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆