if(sizeof(int)>-1)
{
printf("0");
}
else
{
printf("else");
}
it executes the else statement. Why doesnt it follow the if part even if int size>-1.
if(sizeof(int)>-1)
{
printf("0");
}
else
{
printf("else");
}
it executes the else statement. Why doesnt it follow the if part even if int size>-1.
sizoe(int)
yields an integer of type size_t
which is unsigned integer. Due to usual arithmetic conversions in C, -1
gets converted into a size_t
and a hence, -1
becomes SIZE_MAX. Obviously sizeof(int)
is less than SIZE_MAX
and the condition (if
) is false.