Different outputs of sizeof() operator in C and C++.
In C:
int main()
{
printf("%zu\n", sizeof(1 == 1));
return 0;
}
output:
4
In C++:
int main()
{
std::cout << sizeof(1 == 1) << std::endl;
return 0;
}
output:
1
Questions:
- Why are the outputs different?
- Is
sizeofindependent of the OS or compiler? - Is it dependent on language?