C Tutorial/Data Type/Equality


Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Creation of dynamic property PPDStack::$accum is deprecated in /var/www/cppe.ru/www/includes/parser/Preprocessor_DOM.php on line 803

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/includes/exception/MWExceptionHandler.php on line 179

Deprecated: Constant E_STRICT is deprecated in /var/www/cppe.ru/www/vendor/mediawiki/at-ease/src/Functions.php on line 48
Материал из C\C++ эксперт
Перейти к: навигация, поиск

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 =