Right what i want to happen is that the program starts i want u to be able to enter 10 passwords in one after another then once this has been done then ask the user if they want another go.
Whats happening at the moment is that every time u have entered one pass word it asks you if want another go. Ive tryed moveing the for loop and the do loop around and havent had any luck. Anyone have any ideas how to solve this. Thanks
#include <iostream.h>
#include <string.h>
#include <conio.h>
main()
{
const int MAX_SIZE = 10;
int index,count,loop,compare0, compare1,compare2,compare3,compare4,compare5,
compare6,compare7,compare8,compare9;
char *password[] = {"aa0001", "aa0002", "aa0003", "aa0004", "aa0005", "aa0006",
"aa0007", "aa0008", "aa0009", "aa0010"};
char new_password[MAX_SIZE],answer;
count =0;
do
{
for (loop=0; loop <10; loop++)
{
cout << "enter a password ";
cin >> new_password;
clrscr();
index = strlen(new_password);
compare0 = strcmp(password[0],new_password);
compare1 = strcmp(password[1],new_password);
compare2 = strcmp(password[2],new_password);
compare3 = strcmp(password[3],new_password);
compare4 = strcmp(password[4],new_password);
compare5 = strcmp(password[5],new_password);
compare6 = strcmp(password[6],new_password);
compare7 = strcmp(password[7],new_password);
compare8 = strcmp(password[8],new_password);
compare9 = strcmp(password[9],new_password);
if ((compare0 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 1 ACCESS GRANTED!" << endl;
break;
}
if ((compare1 ==0 ) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 2 ACCESS GRANTED!" << endl;
break;
}
if ((compare2 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 3 ACCESS GRANTED!" << endl;
break;
}
if ((compare3 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 4 ACCESS GRANTED!" << endl;
break;
}
if ((compare4 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 5 ACCESS GRANTED!" << endl;
break;
}
if ((compare5 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 6 ACCESS GRANTED!" << endl;
break;
}
if ((compare6 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 7 ACCESS GRANTED!" << endl;
break;
}
if ((compare7 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 8 ACCESS GRANTED!" << endl;
break;
}
if ((compare8 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 9 ACCESS GRANTED!" << endl;
break;
}
if ((compare9 ==0) && (index <7))
{
cout << "VALID PASS" <<endl;
cout <<"Level 10 ACCESS GRANTED!" << endl;
break;
}
{
cout << "INVALID PASS" <<endl;
++count;
}
if (count >2)
{
cout <<"3 wrong attempts" << endl;
count =0;
}
}//for loopend
cout << "would you like another go ";
cin >> answer;
} //do end
while (answer =='y');
return 0;
}