Confusion about the output

前端 未结 4 1114
挽巷
挽巷 2021-01-25 10:05
#include
int main(void)
{
    int i=1,j=-1;
    if((printf(\"%d\",i))<(printf(\"%d\",j)))
        printf(\"%d\",i);
    else 
        printf(\"%d\",j);         


        
4条回答
  •  失恋的感觉
    2021-01-25 11:00

    printf returns the number of characters (not just digits) written.

    So printf("%d",-1) will return 2 not 1

    Similarly printf("%d",1) will return 1

    Making the condition in the if true.

提交回复
热议问题