Use all_of with isupper and islower :
if(all_of(a.begin(), a.end(), &::isupper)){ //Cheking if all the string is lowercase cout << "The string a contain a uppercase letter" << endl; } if(all_of(a.begin(), a.end(), &::islower)){ //Checking if all the string is uppercase cout << "The string b contain a lowercase letter" << endl; }
demo
Alternatively, use count_if if you want to check the number of letters matching your predicate.
krzaq source share