if(computer_number[2] == player_guess[0] || player_guess[1] || player_guess[3] || player_guess[4])
|| does not work like you think it does. For some reason this is a common mistake with beginners.
|| looks at both the left and ride side of it. If either side is nonzero (true), the result is nonzero (true). Otherwise the result is zero (false). The || operator is unaware that the left side of it is a == operation, and therefore does not give you multiple right-hand values for the == operator. It merely combines the output of the == operator with another expression.
EXAMPLE:
1 2 3 4 5
|
int foo = 5;
if(foo == 1 || 2)
{
// this if statement will ALWAYS run
}
|
Notice the if block will run, even though foo does not equal 1 or 2. That's because the compiler interprets this as follows:
(foo == 1 || 2) // start with this
-) look at foo==1. foo contains 5, so this results in false.
(false || 2) // evaluates to this
-) look at '2'. This is nonzero, so it gets interpretted as 'true'
(false || true) // evaluates to this
-) The || operator compares what's on each side of it. Since the right side of it is true, it evaluates to true
(true) // finally evaluates to this
-) Since it gets evaluated to true, the if block executes.
What you probably wanted to do was this:
But I don't doing that because it makes you code get ugly and out of control really fast. A better solution would be to move some of these checks inside a loop... or inside separate functions.