you have checked wrongly, For second if
case with found: The following condition also appears to be contradictory with your comment "if neither value was found"
//if neither value was found
if(!(found == false && found2 == false))
You should remove the !
from the checking. As both of found
and found2
is false
, (found == false && found2 == false)
will result in true
and !(true)
will result in false
.
Again with third if
checking, as it appears with your own comment:
//if both values were found
if(found == false && found2 == false)
you might want it as:
//if both values were found
if(found == true && found2 == true)
However, With the help of bitwise operators(^, &, |)
, i would simply write the three if
condition as follows:
if(found ^ found2 == true) // at least one of them is true: found
{
// do blah blah
}
else if(found & found2 == true) // both of them is true: found
{
// do blah blah
}
else // if above two is false this one obviously true: none of them found
{
}