if, char array and or operator question

is it possible to make a statement like this:
if( A[x] == 'a' || 'b' )
when I want to do this statement like that, I got an compiler error:
if( A[x] == ( 'a' || 'b' ) )
or do I have to seperate it like this:
if( A[x] == 'a' || A[x] == 'b' )

Note: A is a char array. x is any number for the array component. a and b is random characters.

Thanks in advance.
You must do it the last way. The top way instead performs this:

if( (A[x] == 'a') || 'b' ) which is not what you want.
true is "not zero". Operator precidence works as firedraco said, therefore 'b' reduces to true

This means you have:
if( (A[x] == 'a') || true)
true or anything = true so this statement reduces to:
if (true)
which means you will always enter the if statement.
Thanks a lot guys, you are right. That solved my problem. *cheers*
Topic archived. No new replies allowed.