help in password
Aug 24, 2011 at 7:35am Aug 24, 2011 at 7:35am UTC
hi bros i write a code that get pass its not complete but my main problem is
i want to set a code that dont get passwrod over 20 i mean
if 21 entered or higher my code dont accept it and put default value of 20 to c variable
here is my code:
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
string password;
void pass(void )
{
char c;
password="" ;
int a=0;
cout<<"enter password" <<endl;
while (a<2)
{
c=getch();
if (c==13)
{
if (a==0)//enter no number
{pass();break ;}
else
break ;
}
password +=c;
cout<<"*" ;
if (c>='9' )
break ;
a++;
}
}
Aug 24, 2011 at 10:08am Aug 24, 2011 at 10:08am UTC
Currently you allow just 2 while (a<2)
so while (a<20)
would to the job?
You don't need 'a' since you can use password.size()
anyway
Aug 24, 2011 at 11:52am Aug 24, 2011 at 11:52am UTC
no mate i dont mean getting 20 character i mean getting 20 i mean just 2 and 0 can be highly number entered i mean c variable can be:
1 2 3 ...20
Topic archived. No new replies allowed.