Namespaces
Variants
Actions

Predefined Boolean constants (since C23)

From cppreference.com
< c‎ | language
 
C
 
C language
 
Expressions

Contents

[edit] Syntax

true (1) (since C23)
false (2) (since C23)

[edit] Explanation

Keywords true and false represent predefined constants. They are non-lvalues of type bool.

[edit] Notes

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.

[edit] Example

#include <assert.h>
 
int main()
{
    assert(true == 1 && 0 == false);
}

[edit] References

  • C23 standard (ISO/IEC 9899:2024):
  • 6.4.4.6 Predefined constants (p: 66)

[edit] See also

C++ documentation for Boolean literals

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant