C Tutorial/Data Type/Equality
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 =
#include <stdio.h>
main(){
int i = 5;
if(i == 5){
printf(" ==. \n");
}
if(i=4){
printf("do not use = ");
}
}
==. do not use =