A Boolean variable can be used to hold the integer values 0 or 1, or the literals true or false, which are implicitly promoted to the integers 1 and 0 respectively, whenever an arithmetic value is necessary. The Boolean type is unsigned and has the lowest ranking in its category of standard unsigned integer types; it may not be further qualified by the specifiers signed, unsigned, short, or long. In simple assignments, if the left operand is a Boolean type, then the right operand must be either an arithmetic type or a pointer.
Boolean type is a C99 feature. To declare a Boolean variable, use the _Bool type specifier.
The token bool is recognized as a keyword in C only when used in a vector declaration context and vector support is enabled.
To declare a Boolean variable in C++, use the bool type specifier. The result of the equality, relational, and logical operators is of type bool: either of the Boolean constants true or false.
_Bool f(int a, int b)
{
return a==b;
}
If a and b have the
same value, f returns true. If not, f returns false.