Can someone help me with this?

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?

#include <iostream>
#include <cstring>
#include <cctype>

using namespace std;

const int SIZE = 7;
char password[SIZE + 1];

bool verify_pass(const char *userinput)
{if (strcmp(userinput, password) == 0)

{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;}
if (strcmp(userinput, password) == 0)

you never set 'password'.
I don't need to set a password because it can be anything as long as it is 7 characters in length and has atleast a digit or a "$".
Hi efffive,

I have a question for you. If you can answer the question then maybe you'll be able to solve your problem.

What do you think the line mentioned by mutexe does ?

 
 if (strcmp(userinput, password) == 0)
Topic archived. No new replies allowed.