This will give you the correct answer, but it won't work the way you think it will.
Conditions are evaluated individually. This means that for the following code :
char* a = "test";
int b = 2;
int c = 3;
int d = 4;
if(strlen(a) != b || c || d )
{
…
}
... will do the following :
if((4 != 2) || (3) || (4))
Since positive integers are evaluated as true :
if((true) || (true) || (true))
Which evaluates as true
.
What you really want there is the following :
if((strlen(a) != b) || (strlen(a) != c) || (strlen(a) != d))
{
…
}
Or, for a better optimized version :
int len = strlen(a);
if((len != b) || (len != c) || (len != d))
{
…
}
EDIT :
As it was pointed out in the comments, what you really want to validate here is if a string length isn't one of three things. So what you need is the AND operator.
int len = strlen(a);
if((len != b) && (len != c) && (len != d))
{
…
}