Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cctype>
- #include<cstdlib>
- #include<cstring>
- #include<string>
- using namespace std;
- void wordTest(char password1[], int size1);
- int main()
- {
- const int size = 20;
- char password[size];
- cout << "type your new password: ";
- cin.getline(password, size);
- if (strlen(password)<12)
- cout << "password must have at least 12 characters.\n";
- wordTest(password, size);
- return 0;
- }
- void wordTest(char password1[], int size1)
- {
- bool flag = false, flag1 = false, flag2 = false, flag3 = false;
- for (int count = 0; count < size1; count++)
- {
- if (isupper(password1[count]))
- {
- cout << count;
- flag = true;
- }
- }
- for (int count = 0; count < size1; count++)
- {
- if (isdigit(password1[count]))
- {
- flag1 = true;
- }
- }
- for (int count = 0; count < size1; count++)
- {
- if (islower(password1[count]))
- {
- flag2 = true;
- }
- }
- for (int count = 0; count<size1; count++)
- {
- if (ispunct(password1[count]))
- {
- flag3 = true;
- }
- }
- if (!flag)
- cout << "need one capital letter.\n";
- if (!flag1)
- cout << "need at least one digit.\n";
- if (!flag2)
- cout << "need at least one lowercase letter.\n";
- if (!flag3)
- cout << "need at least one special character.\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement