diff options
Diffstat (limited to 'devdocs/c/language%2Fbool_constant.html')
| -rw-r--r-- | devdocs/c/language%2Fbool_constant.html | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/devdocs/c/language%2Fbool_constant.html b/devdocs/c/language%2Fbool_constant.html new file mode 100644 index 00000000..f3be4efd --- /dev/null +++ b/devdocs/c/language%2Fbool_constant.html @@ -0,0 +1,21 @@ + <h1 id="firstHeading" class="firstHeading">Predefined Boolean constants <span class="t-mark-rev t-since-c23">(since C23)</span> +</h1> <h3 id="Syntax"> Syntax</h3> <table class="t-sdsc-begin"> <tr class="t-sdsc"> <td> <code>true</code> </td> <td> (1) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> +</tr> <tr class="t-sdsc"> <td> <code>false</code> </td> <td> (2) </td> <td> <span class="t-mark-rev t-since-c23">(since C23)</span> </td> +</tr> +</table> <h3 id="Explanation"> Explanation</h3> <p>Keywords <code>true</code> and <code>false</code> represent predefined constants. They are <a href="value_category#Non-lvalue_object_expressions" title="c/language/value category">non-lvalues</a> of type <a href="types" title="c/language/types" class="mw-redirect"><code>bool</code></a>.</p> +<h3 id="Notes"> Notes</h3> <p>See <a href="conversion#Integer_conversions" title="c/language/conversion">integral conversions</a> for implicit conversions from <code>bool</code> to other types and <a href="conversion#Boolean_conversion" title="c/language/conversion">boolean conversions</a> for the implicit conversions from other types to <code>bool</code>.</p> +<p>Until C23, <code>true</code> and <code>false</code> were implemented as macros provided in <a href="../types" title="c/types"><code><stdbool.h></code></a>. An implementation may also define <code>bool</code>, <code>true</code>, and <code>false</code> as predefined macros in C23 for compatibility.</p> +<h3 id="Example"> Example</h3> <div class="t-example"> <div class="c source-c"><pre data-language="c">#include <stdio.h> + +int main(void) +{ + printf("%d\n%d\n", true, false); +}</pre></div> <p>Output:</p> +<div class="text source-text"><pre data-language="c">1 +0</pre></div> </div> <h3 id="See_also"> See also</h3> <table class="t-dsc-begin"> <tr class="t-dsc"> <td colspan="2"> <span><a href="https://en.cppreference.com/w/cpp/language/bool_literal" title="cpp/language/bool literal">C++ documentation</a></span> for <span class=""><span>Boolean literals</span></span> </td> +</tr> </table> <div class="_attribution"> + <p class="_attribution-p"> + © cppreference.com<br>Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.<br> + <a href="https://en.cppreference.com/w/c/language/bool_constant" class="_attribution-link">https://en.cppreference.com/w/c/language/bool_constant</a> + </p> +</div> |
