What's the “condition” in C interview test?

后端 未结 30 2869
旧时难觅i
旧时难觅i 2020-12-05 02:37

Would it be possible to print Hello twice using single condition?

if  \"condition\"
  printf (\"Hello\");
else
  printf(\"World\");         


        
30条回答
  •  庸人自扰
    2020-12-05 03:11

     #include
      int main()
    {
     if(! printf("Hello"))
         printf ("Hello");
    else
        printf ("World");
     return 0;
    }
    

    Because Printf returns the number of character it has printed successfully.

提交回复
热议问题