Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #include<iostream>
  2. #include<cctype>
  3. #include<cstdlib>
  4. #include<cstring>
  5. #include<string>
  6. using namespace std;
  7.  
  8. void wordTest(char password1[], int size1);
  9.  
  10. int main()
  11. {
  12. const int size = 20;
  13. char password[size];
  14. cout << "type your new password: ";
  15. cin.getline(password, size);
  16.  
  17. if (strlen(password)<12)
  18. cout << "password must have at least 12 characters.\n";
  19.  
  20. wordTest(password, size);
  21.  
  22.  
  23. return 0;
  24. }
  25. void wordTest(char password1[], int size1)
  26. {
  27. bool flag = false, flag1 = false, flag2 = false, flag3 = false;
  28.  
  29. for (int count = 0; count < size1; count++)
  30. {
  31. if (isupper(password1[count]))
  32. {
  33. cout << count;
  34. flag = true;
  35. }
  36. }
  37. for (int count = 0; count < size1; count++)
  38. {
  39. if (isdigit(password1[count]))
  40. {
  41. flag1 = true;
  42. }
  43. }
  44. for (int count = 0; count < size1; count++)
  45. {
  46. if (islower(password1[count]))
  47. {
  48. flag2 = true;
  49. }
  50. }
  51. for (int count = 0; count<size1; count++)
  52. {
  53. if (ispunct(password1[count]))
  54. {
  55. flag3 = true;
  56. }
  57. }
  58.  
  59. if (!flag)
  60. cout << "need one capital letter.\n";
  61. if (!flag1)
  62. cout << "need at least one digit.\n";
  63. if (!flag2)
  64. cout << "need at least one lowercase letter.\n";
  65. if (!flag3)
  66. cout << "need at least one special character.\n";
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement