mardi 14 janvier 2020

Print statement in if, switch and while condition of c

Can someone explain why the code prints "HelloWorld" and not "HelloWorldThere" ? Also why does it print anything at all as there are no conditions in if or switch statements ? Here is the code:

#include <stdio.h>

int main()
{
    int a, b;

    if(printf("Hello"))
        switch(printf("World"))
            while(printf("There"))
            {
                return 0;
            }
}

Aucun commentaire:

Enregistrer un commentaire