#include <iostream>
#include <cstring>
#include <cctype>
using namespace std;             
bool testPass(char []);
int main()
{
    char *password;
    int length; 
    int numCharacters; 
    cout << "Please enter how many characters you would like your\npassword to be.";
    cout << " Your password must be at least 6 characters long." << endl;
    cin >> numCharacters;

    while (numCharacters < 6)
    {
        cout << "Please enter a password length of at least 6 characters." << endl;
        cin >> numCharacters;
    }

    password = new char[numCharacters+1];

    cout << "Please enter a password that contains at least one uppercase letter, ";
    cout << "one\nlowercase letter, and at least one digit." << endl;
    cin >> password;
    length = strlen(password);
    while (length != numCharacters)
    {
        cout << "Your password is not the size you requested. ";
        cout << "Please re-enter your password." << endl;
        cin >> password;
        length = strlen(password);
    }

    if (testPass(password))
        cout << "Your password is valid." << endl;
    else
    {
        cout << "Your password is not valid. ";
        cout << "Please refer to the above warning message." << endl;
    }

    delete[] password ;
    return 0;
}

bool testPass(char pass[])
{
    bool aUpper = false,
         aLower = false,
         aDigit = false ;
    for ( int i = 0 ; pass[i] ; ++i )
        if ( isupper(pass[i]) )
            aUpper = true ;
        else if ( islower(pass[i]) )
            aLower = true ;
        else if ( isdigit(pass[i]) )
            aDigit = true ;
    if ( aUpper && aLower && aDigit )
        return true;
    else
        return false ;
}

asked 16 Apr '15, 01:28

hadisur_rahman's gravatar image

hadisur_rahman
514

closed 16 Apr '15, 16:58

__salman__'s gravatar image

__salman__ ♦♦
1.1k211

what is your question? @hadisur_rahman

(16 Apr '15, 03:15) __salman__ ♦♦

Add some more code in c/c++ related to show the output password strong or password weak or too short????

(16 Apr '15, 12:46) hadisur_rahman

Is it some kind of assignment you are doing? @hadisur_rahman

(16 Apr '15, 13:23) __salman__ ♦♦

yes bro..would u like to help me???

(16 Apr '15, 16:01) hadisur_rahman

no. try yourself. if you get stuck then ask help here.

(16 Apr '15, 16:55) __salman__ ♦♦

ay upodesh sobi deta pare..

(17 Apr '15, 15:50) hadisur_rahman
2

This is not a site to ask people to do one's assignment, there are plenty of other sites to do that. Doing this for assignments is kind of cheating. This is a platform for answering questions, so try doing your assignment by yourself, if you get stuck, post a specific question on your problem. People here are willing and ready to help.

(17 Apr '15, 19:01) 0605002
showing 5 of 7 show 2 more comments

The question has been closed for the following reason "Other" by __salman__ 16 Apr '15, 16:55

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×402
×131

question asked: 16 Apr '15, 01:28

question was seen: 1,217 times

last updated: 18 Apr '15, 05:47