Given an int
array database
, instead of
if (user_input == int database[0] || user_input == int database[1])
{
// ...
}
Could I do something more concise, like this?
if (user_input == any variable from database)
{
// ...
}
Given an int
array database
, instead of
if (user_input == int database[0] || user_input == int database[1])
{
// ...
}
Could I do something more concise, like this?
if (user_input == any variable from database)
{
// ...
}
What you probably are looking for is std::find
algorithm.
E.g.
if(std::end(database) != std::find(std::begin(database), std::end(database), user_input)) { ... }