return true if c1 < c2 (ignoring case), false otherwise : string compare « String « C++






return true if c1 < c2 (ignoring case), false otherwise

  
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>

using namespace std;

// return true if c1 < c2 (ignoring case), false otherwise
bool less_than_insensitive( char c1, char c2 )
{
   return tolower( static_cast<unsigned char>( c1 ) ) < tolower( static_cast<unsigned char>( c2 ) );
}

int main( )
{
}
  
    
  








Related examples in the same category

1.String: equals
2.string overloaded equality and relational operators
3.Compare string ignoring the case
4.Compare sub string: string4.compare( 0, string2.length(), string2 )
5.Use == > and < to compare strings
6.Use string.compare to compare two strings
7.Compare strings by index: string1.compare( 2, 5, string3, 0, 5)
8.Set with functor for string comparison
9.Use std::lexicographical_compare to compare two char arrays
10.Compare strings
11.return true if c1 equals c2 (regardless of case), false otherwise