jean jean - 1 year ago 138
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;


Answer Source

you can use standard algorithm std::all_of

if( std::all_of( str.begin(), str.end(), islower ) { // all lowercase
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download