Hello I've written a code that request for a password and its suppose to look like this.
Sample Output (inputs in bold)
Please enter a password: pass6
Passwords must be at least 7 characters long
Please enter a password: TarrantNW
Passwords must include a digit or dollar sign (0-9, $)
Please enter a password: Tccd-03
Thank you, that is a valid password
But when I run the program it stops at "Passwords must be at least 7 characters long" and the box closes and I have no idea where I should put the loop, could someone help me?
{cout << "Thank you, that is a valid password.\n";
return true;}
else{
cout << "Wrong Password\n";
return false;}}
bool verify_chars(const char *userinput)
{int i, len = strlen(userinput);
if (len < SIZE)
{cout << "Passwords must be at least " << SIZE << " characters long\n";
return false;
}
for (i = 0; i < len; ++i)
{
if (isdigit(userinput[i]) || ('$' == userinput[i]))
{return true;}
}
cout << "Passwords must include a digit or dollar sign (0-9, $)\n";
return false;
}
int main()
{char userinput[1024];
cout << "Please enter a password:\n";
cin >> userinput;
if (verify_chars(userinput) == true)
{verify_pass(userinput);}
return 0;}