compare two strings in c++ ignorecase code example

Example 1: c++ compare strings ignore case

#include <boost/algorithm/string.hpp>
// Or, for fewer header dependencies:
//#include <boost/algorithm/string/predicate.hpp>

std::string str1 = "hello, world!";
std::string str2 = "HELLO, WORLD!";

if (boost::iequals(str1, str2))
{
    // Strings are identical
}

Example 2: how to compare lower case character to uppercase cpp

for(int i=0;i<str.size();i++){
int c = str[i]; 
        if (islower(c))  
            str[i] = toupper(c);
}

Tags:

Cpp Example