You can use std::find
for this:
#include <algorithm> // for std::find
#include <iterator> // for std::begin, std::end
int main ()
{
int a[] = {3, 6, 8, 33};
int x = 8;
bool exists = std::find(std::begin(a), std::end(a), x) != std::end(a);
}
std::find
returns an iterator to the first occurrence of x
, or an iterator to one-past the end of the range if x
is not found.