Mega Code Archive

 
Categories / C++ / String
 

Return true if c1 equals c2 (regardless of case), false otherwise

#include <algorithm> #include <cctype> #include <iostream> #include <string> using namespace std; // return true if c1 equals c2 (regardless of case), false otherwise bool equal_to_insensitive( char c1, char c2 ){    return tolower( static_cast<unsigned char>( c1 ) ) == tolower( static_cast<unsigned char>( c2 ) ); } int main( ) { }