C Tutorial/Data Type/Equality
Версия от 17:21, 25 мая 2010; (обсуждение)
Comparing the equality operator (==) with the "=" assignment operator.
a b a = b a == b 5 3 a = 3 (true) false 7 0 a = 0 (false) false 0 0 a = 0 (false) true
To test two expressions for equality, use == instead of =
<source lang="cpp">#include <stdio.h> main(){
int i = 5; if(i == 5){ printf(" ==. \n"); } if(i=4){ printf("do not use = "); }
}</source>
==. do not use =