I'm fairly new to C++ so forgive me if this is a stupid question, but I've searched and I only found something about std::find
which doesn't seem to do what I want (perhaps I'm not using it properly).
As an example, say I have a basic program that can store your gender. I have an if statement that just checks if the user entered "male" or "Male" and then does whatever I want it to do like so:
if(gender == "male" || gender == "Male"){
// Do stuff
}
I'd like to expand it so a user can enter "m" or "M" as well, and it'll be detected as male. However, I think the if statement would be a bit messy so I'm thinking about sticking the options into a simple array and doing:
if(gender is in maleArray){
// Do stuff
}
Is this possible? I'm not too bothered about any bad practices involved as this is a learning scenario, although any (useful) criticisms or alternatives are appreciated, as are examples!
Thanks in advance, hope I made it clear enough.