Arr[5] = {1, 2, 3, 4, 5}
std::find
12345678910111213141516
#include <iostream> #include <string> #include <algorithm> int main() { const int SIZE = 6; std::string array[SIZE] = { "apple", "pear", "pineapple", "orange", "banana", "grape"}; int index = std::find(array, array+SIZE, "orange") - array; if (index == SIZE) std::cout << "not found\n"; else std::cout << array[index] << " was found at index " << index << '\n'; }
orange was found at index 3