Is there an easy way to determine if a value is at all present in an array? In python you can type:

if value in list:
              do this

But how could i do that in c++? I would like something like this:

if(value "is present in" array1)
              {
              do this;
              }

Thanks everyone!

You pretty much search the array and see if the item is in it or not. If the array is sorted, a binary search will do this pretty fast. If it's not sorted, you have to loop over each object in the array:

for(int i = 0; i < arraySize; i++)
  // check if array[i] == itemToFind
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.