lundi 9 août 2021

Unexpected Output of c program [duplicate]

    void main()
    {
     clrscr();
     if(sizeof(!6.0))
     printf("%d",sizeof(6.0,2));
     else
     printf("i don't know");
     getch();
    }

The output of this function is 4. As I can understand in the expression if(sizeof(!6.0)) -> the expression sizeof(!6.0) returns: 0

so sizeof(0) is 4 (in 64 bit system) and expression if(sizeof(!6.0)) executes as its True. But in printf("%d",sizeof(6.0,2)) the output is 4 .

So I want to know why sizeof() is returning 4 byte and how can it take two values without any warning and error by compiler.

Aucun commentaire:

Enregistrer un commentaire