== or =?

== is an equality test. It returns either true (1) or false(0).
= is assignment. The value of the left becomes the value of the right.

1
2
3
4
5
int a = 6;  // an assignment a is set to 6
int b = 7; // another assignment b is set to 7

if (a == b)  // an equality test. The statement following is only executed if a is equal to b. The values
// of a nd b are not changed 

note that in c++ it is legal to do this:

if (x = y)

which says: "assign x the value of y. If x is not zero, the expression is true, else it is false"
which is nothing like "If x is equal to y". This is a common mistake, as few programs ever want to the assignment version: it is almost always wrong.
Last edited on
Another initial post removed by the OP!!!!!
Please stop feeding the trolls.
A question that retarded is probably not real.
Topic archived. No new replies allowed.