Illustrating the generic lexicographical_compare algorithm : lexicographical_compare « STL Algorithms Sorting « C++ Tutorial






#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;


int main()
{
  string s("helio");
  string s2("hello");

  vector<char> vector1(s.begin(), s.end());
  vector<char> vector2(s.begin(), s.end());

  // Show that vector1 is lexicographically less than vector2:
  bool result = lexicographical_compare(vector1.begin(),vector1.end(), vector2.begin(), vector2.end());

  cout << result;
  return 0;
}
0








27.3.lexicographical_compare
27.3.1.Illustrating the generic lexicographical_compare algorithm
27.3.2.Use std::lexicographical_compare to compare two char arrays