I have an if statement that looks as follows:
int count=0;
string Check;
if ((count==4 && Check!="-s")||(count==4 && Check!="-S"))
If count equals 4 and Check equals "-s" or "-S" it still enters this if statement because of the count == 4. It totally seems to ignore the second part. Is there something I’m doing wrong?
Well, if
Checkis"-S", then it will not even check the second pair of conditions, because you check with||. The same holds true for the opposite case. If one is false, the other is true. Replace that with a&&.Now the corrected version: