jean jean - 7 months ago 35
C++ Question

Check if string has letter in uppercase or lowercase

i would like to know if it's possible check if one letter of a string is capitalized. Other way to see it, if all letters in the string are uppercase or lowercase. Example:

string a = "aaaaAaa";
string b = "AAAAAa";

if(??){ //Cheking if all the string is lowercase
cout << "The string a contain a uppercase letter" << endl;
if(??){ //Checking if all the string is uppercase
cout << "The string b contain a lowercase letter" << endl;



you can use standard algorithm std::all_of

if( std::all_of( str.begin(), str.end(), islower ) { // all lowercase