Question about if statements

Is there a way to simplify if (n=='y' || n=='j'|| n=='d') without writing a function that returns a boolean?
No.
> without writing a function

Use a function that is already written for us?

if( std::strchr( "yjd", n ) ) // http://en.cppreference.com/w/cpp/string/byte/strchr

Well, technically: if( n && std::strchr( "yjd", n ) )
Last edited on
Topic archived. No new replies allowed.