The single equal sign (=) is used for assignment, assigning the right value to the left variable; the double equal sign (==) is used for comparison, to determine whether the two operands are equal, and return 0 (false) or 1 (real).
The difference between single equal sign and double equal sign in C language
In C language, single equal sign (=
) and the double equal sign (==
) have different usages:
Single equal sign (=
)
Double equal sign (==
)
Specific differences
Single equal sign ( | = )
| Double equal sign (==)
|
---|---|---|
Assignment | Comparison | |
The left operand is assigned the right value | The return value indicates whether the two operands are equal (true or False) | |
None | 0 (False) or 1 (True) |
<code class="c">int x = 10; // 赋值
if (x == 10) { // 比较
// 代码块
}</code>
The single equal sign cannot be used interchangeably with the double equal sign.
strcmp()
function.
The above is the detailed content of The difference between single equal sign and double equal sign in C language. For more information, please follow other related articles on the PHP Chinese website!