vendredi 5 octobre 2018

Why does sizeof(!0) print 1 instead of 4?

#include <iostream>

int main()
{
    std::cout<<sizeof(0);
    return 0;
}

Here, sizeof(0) is 4 in C++ because 0 is an integer rvalue.

But, If I write like this:

std::cout<<sizeof(!0);

here, sizeof(!0) is 1. But, !0 means it print 1, which is also, int type.

then, Why does sizeof(!0) print 1 instead of 4? What am I miss here?

Aucun commentaire:

Enregistrer un commentaire