You probably need to use ==
(equality) rather than =
(assignment). I see you've changed that in your question.
The cause of the error message is:
P2d1 =! P2d2
The inequality operator is !=
, not =!
.
The way you're written it, it's an assignment =
followed by a unary "not" !
. And since =
has very low precedence, this:
(P1d1 == P1d2 && P2d1 =! P2d2)
is equivalent to this:
((P1d1 == P1d2 && P2d1) = !P2d2)
and of course (P1d1 == P1d2 && P2d1)
is not a valid target for an assignment.
This is one of the more ahem interesting things about programming in C. In some languages, a minor typo is likely to introduce a syntax error, and the compiler's error message is likely to tell you exactly what the problem is. In C, minor typos can easily result in code that's still syntactically correct, but that has some absurd meaning -- or, in your case, that produces an error message that's not very illuminating.
A good approach, if you don't understand what a compiler error message means, is to ignore what it says and just look carefully at the earliest line of code that the compiler complains about.