Home >Backend Development >C#.Net Tutorial >What is the difference between = and == in C language?
In C language, = is the assignment operator, used to change the value of a variable; == is the equality comparison operator, used to compare the values of two expressions and return a Boolean value.
The difference between = and == in C language
In C language, = and == are two Different operators with different functions.
= (assignment operator)
== (Equality comparison operator)
Returns a Boolean value:
Example:
<code class="c">int x = 10; int y = 10; x = y; // 将 y 的值(10)赋值给 x int result = (x == y); // 比较 x 和 y 的值,返回 true</code>
Key Difference:
So, in C language, = is used for assignment and == is used for equality comparison.
The above is the detailed content of What is the difference between = and == in C language?. For more information, please follow other related articles on the PHP Chinese website!