So yea I'm new to programming. I've been trying to come up with some original programs and decided to make a password program. My problem is that i can't figure out how to get the program to accept multiple passwords. I know there is a way to do it with strings but i can't figure it out.
*just a side note it's probably pretty sloppy*
Code:
#include <cstdlib>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
string password[4];
password[0]="111111";
password[1]="222222";
password[2]="333333";
password[3]="444444";
string entry;
string crctpass;
int evaluate;
cout<<"Please type in your password:";
for(int x=0;x<5;x++)
{
crctpass=password[t];
cin>>entry;
if(entry==crctpass)
{
cout<<"You have entered the correct password!\n";
evaluate=1;
break;
}
else if(x<4)
{
cout<<"Incorrect, enter your password again:\n";
}
else
{
cout<<"Too many failed attempts.\n";
evaluate=0;
}
}
if(evaluate==1)
{
cout<<"Program booting...\n";
}
else
{
cout<<"Shutting down...\n";
}
system("PAUSE");
return EXIT_SUCCESS;
}
That's what i have so far. I can't figure out how to loop it so variable 't' increments changing the password that is checked without messing up the loop that allows the user to try and input different passwords.