mardi 24 septembre 2019

Why printf inside if condition works in c?

if(printf("Hello world")){}
The output for above code is
Hello world

My friend told me that the function printf returns the length of characters which is non zero here, so the condition is true. But I can't understand why it executes that printf statement. Shouldn't printf be executed only when it is inside { } ?

Aucun commentaire:

Enregistrer un commentaire