Quantcast
Channel: what is the meaning of == sign? - Stack Overflow
Viewing all articles
Browse latest Browse all 9

Answer by Carl for what is the meaning of == sign?

$
0
0

Think about it like this:

= means give something a value.

== means check if it is equal to a value.

For example

int val = 5; //val is 5//= actually changes val to 3val = 3; //== Tests if val is 3 or not. //note: it DOES NOT CHANGE the value of val.val == 3; int new_val = val == 3; //new_val will be 1, because the test is true//the above statement is the same asbool is_val_3 = false;if( val == 3 )   is_val_3 = true;int new_val;new_val = is_val_3;//putting it together, val = new_val == 2; //sets val to 0. do you understand why now?

Viewing all articles
Browse latest Browse all 9

Trending Articles