In C language, the exclamation point (!) represents the logical NOT operator, which is used to negate an expression so that its result is the opposite of the original expression.
What does ! mean in C language?
In C language, the exclamation point (!) represents the logical NOT operator, which negates an expression. That is, if the expression is true, the result is false; if the expression is false, the result is true.
Usage:
<code class="c">!expression;</code>
Among them, expression
is the expression to be negated.
Example:
<code class="c">int x = 10; if (!x) { // x 为 0 时执行 }</code>
In this example, !x
is equal to false
because x
is non-zero value. Therefore, the if
statement will not be executed.
Priority:
The logical NOT operator has higher priority than the logical AND and OR operators, but lower than the arithmetic operator.
Application scenarios:
The logical NOT operator is usually used in the following scenarios:
The above is the detailed content of What does ! mean in c language?. For more information, please follow other related articles on the PHP Chinese website!