Search code examples
c++iteratorstrcmp

C++; how to compare the string values of different iterators traversing the same string vector


If two vector iterators iit and min traverse the same vector<string>, how can i compare the string values at the locations the pointers are at? i want to be able to do this:

(strcmp(*iit, *min) < 0)

Solution

  • Use the std::basic_string::compare member function:

    iit->compare(*min) < 0