Home > Article > Backend Development > The difference between = and == in c++
The difference between = and == in C: "=" is an assignment operator, assigning a value to a variable or reference; "==" is an equality operator, comparing whether two values are equal and returning a Boolean value .
The difference between = and == in C
The = and == in C are two different Operators, with different functions and uses.
= (assignment operator)
int x = 5;
== (Equality operator)
if (x == 5)
Table 1: Main differences between = and ==
Features | = | == |
---|---|---|
Assignment | Comparison | |
None | Boolean value | |
can be assigned to a variable or reference | can be any expression | |
after assignment Variable value | Boolean value, indicating whether the two values are equal |
Note:
The above is the detailed content of The difference between = and == in c++. For more information, please follow other related articles on the PHP Chinese website!