Does C use short circuit evaluation even when arguments are function calls?

前端 未结 3 1685
无人共我
无人共我 2021-01-25 03:40

I know that logical operators do short-circuit checking. That is, if there is a statement like A && B && C, then if A is false,

3条回答
  •  抹茶落季
    2021-01-25 04:24

    yes, it is true in function calls also.

    #include
    void main()
    {
        if(0&&printf("hello"))
        {
            printf("true");
    
        }
        else 
            printf("false");
    }
    

    for example consider the above code, it will give output as false. However replacing 0 by 1 in "if condition' will give output as "hellotrue."

提交回复
热议问题