In C language, the "=" assignment operator is used to assign values to variables, while the "==" equality comparison operator is used to compare whether the values of two expressions are equal. Return true to indicate equality, false Indicates inequality.
The difference between "=" and "==" in C language
In C language, "= " and "==" are two different operators with different functions.
"=": assignment operator
Assignment operator "=" is used to assign a value to a variable. For example:
<code class="c">int x = 5;</code>
This statement assigns the value 5 to variable x.
"==": Equality comparison operator
Equality comparison operator "==" is used to compare whether the values of two expressions are equal. Unlike "=", "==" does not perform an assignment, but returns a bool value representing the result of the comparison:
For example:
<code class="c">int x = 5; if (x == 5) { // 执行语句 ... }</code>
This if statement uses "==" to compare whether the value of variable x is equal to 5. If true, the statements in the if block are executed.
Summary
The above is the detailed content of In C language, the difference between = and ==. For more information, please follow other related articles on the PHP Chinese website!