true | (1) | (since C23) |
false | (2) | (since C23) |
Keywords true
and false
represent predefined constants. They are non-lvalues of type bool
.
See integral conversions for implicit conversions from bool
to other types and boolean conversions for the implicit conversions from other types to bool
.
Until C23, true
and false
were implemented as macros provided in <stdbool.h>
. An implementation may also define bool
, true
, and false
as predefined macros in C23 for compatibility.
#include <stdio.h> int main(void) { printf("%d\n%d\n", true, false); }
Output:
1 0
C++ documentation for Boolean literals |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/c/language/bool_constant