Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      Predefined Boolean constants(since C23)

      From cppreference.com
      <c‎ |language
       
       
       
       

      Contents

      [edit]Syntax

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

      [edit]Explanation

      Keywordstrue andfalse represent predefined constants. They arenon-lvalues of typebool.

      [edit]Notes

      Seeintegral conversions for implicit conversions frombool to other types andboolean conversions for the implicit conversions from other types tobool.

      Until C23,true andfalse were implemented as macros provided in<stdbool.h>. An implementation may also definebool,true, andfalse as predefined macros in C23 for compatibility.

      [edit]Example

      Run this code
      #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 forBoolean literals
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/language/bool_constant&oldid=176320"

      [8]ページ先頭

      ©2009-2025 Movatter.jp