You can also try this.
This is according to your post
hello i'm trying to figure out how to write a program in c++ that check when i insert a password and force me to add at least 2 capital letters and 2 numbers in the password (you've seen this before right? when signing up for new account and checks for password stringth)
Below is a simple code to mimic such thing.
bool chkUperDegitPwd( const std::string pwd){
static size_t sCount=0; // static count
for(auto &p: pwd){ // >= c++11
if(std::isdigit(p)){
sCount++;
}else if(std::isalpha(p)){
if(std::isupper(p)){
sCount++;
}
}
}
return pwd.length() == sCount ?true:false;
}
// use case
std::string pwd;
std::getline(std::cin,pwd);
if(chkUperDegitPwd(pwd)){
//do your stuff
}else{
// password error
}