I am trying to write a program to check the
security level of a user input password. The program is supposed to report the security level based on the following 5-star scheme:
contains at least one lower case letter
contains at least one upper case letter
contains at least one digits
has a length longer than 6
contains at least one symbol (non-letter and non-digit)
1 star for each items (hence, maximum 5 stars)
But unfortunately it does not work and i do not know why, can anyone please help?
Also, Read the user input as characters until the user input ‘!’, but i don't know how can i accomplish this, plz help.
Thank You
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
#include <cctype>
using namespace std;
int size ;
int main(){
char *pw ;
pw = new char[size];
int lvofsec = 0;
cin >> pw[size];
for(int i = 0; i <= (sizeof(pw) - 1); i ++){
if(islower(pw[i])){
lvofsec = lvofsec + 1;
break;
}
}
for(int j = 0; j <= (sizeof(pw) - 1); j ++){
if(isupper(pw[j])){
lvofsec = lvofsec + 1;
break;
}
}
for(int k = 0; k <= (sizeof(pw) - 1); k ++){
if(isdigit(pw[k])){
lvofsec = lvofsec + 1;
break;
}
}
for(int m = 0; m <= (sizeof(pw) - 1); m ++){
if(ispunct(pw[m])){
lvofsec = lvofsec + 1;
break;
}
}
if(sizeof(pw) > 6){
lvofsec = lvofsec + 1;
}
cout << "The security level of your password is " << lvofsec << "*" << endl;
return 0;
}
|