password character length

Can someone show me how to write a programme that knows how many letters your password is, I'm trying to create a password page in which you're password must be at least 6 characters long with 1 number.
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
#include <iostream>
#include <algorithm>
#include <cctype>
#include <string>
using namespace std;

int main() 
{
	

string password = "ba55555as";

if (password.length() < 6)
{
	  cout << "short" ;
  // password too short
}
else
{
  // password is long enough
	  cout << "long" ;

  // use of a std algorithm and lambda function. 
  if  (std::find_if (password.begin(), 
                     password.end(),
                     [](char s) 
                      {
                     	 return (0 != std::isdigit(s));
                      })  != password.end())
                     	 
  {
     // it contains at least one digit
     	  cout << "digit" ;
   }
   else
   {
       // doesn't contain any digits
       	  cout << "no digit" ;
    }
}


}
Registered users can post here. Sign in or register to post.