i'm trying to make a password system for my program. a user will input upto 20 chars, and if the password is correct, load the main program and if not, loop until the user gives up or enters the correct answer.
here is the code
void Password(char pass);
int main()
{
/* how do i insert the call to Password() ? */
cout << "test code here!";
}
void Password(char pass)
{
do
{
char pass[20];
cout << "Password: ";
cout << "\n";
cin.get(pass[20]);
if (pass = "test")
main();
else
{
cout << "\n\nError: Incorrect Password!";
cin.ignore(80);
}
}
while( pass != 'test');
}
i have 2 problems:
1. on the line "if (pass = "test") it's giving me an:
expression must be modifyable lvalue error.
2. i'm not entirely sure how to add this into the main program, so it will run Password() before continuing.
can somebody please help me? thanks.