Use std::lexicographical_compare to compare two char arrays : lexicographical_compare « STL Algorithms Sorting « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

#include <algorithm>
#include <vector>
#include <iterator>

int main()
{
   char c1[ 10 ] = "HELLO";
   char c2[ 10 ] = "BYE BYE";

   // perform lexicographical comparison of c1 and c2
   bool result = std::lexicographical_compare( c1, c1 + 10, c2, c2 + 10 );
   cout << c1 << ( result ? " is less than " :
      " is greater than or equal to " ) << c2 << endl;

   return 0;
}
HELLO is greater than or equal to BYE BYE








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