Home >Backend Development >C++ >In c++! How to use
The exclamation point (!) in C represents a logical NOT operation, which inverts the Boolean value: if the value is true, return false; if the value is false, return true.
Exclamation mark (!) usage in C
In C, the exclamation mark (!) operator represents logic Not operation. Its function is to invert a Boolean value (true or false).
Syntax:
<code class="cpp">!expression</code>
Among them, expression
is the Boolean expression to be inverted.
Return value:
This operator returns a Boolean value, indicating the result of the inversion of the expression. Specifically:
expression
is true, returns false. expression
is false. Example:
<code class="cpp">bool isTrue = true; bool isFalse = false; bool notTrue = !isTrue; // false bool notFalse = !isFalse; // true</code>
Other usages:
In addition to the logical NOT operation, the exclamation point is also used in C It has the following usage:
The above is the detailed content of In c++! How to use. For more information, please follow other related articles on the PHP Chinese website!