Hi , i'm using vectors for the first time in a project , my project about Bnking system , my idea is the user enter a name and the program will search for it in the vector same as the password , How can code this ?
I try and this what i have so far . a lot of red lines in the code and i dont know why and who to fix it .
#include<conio.h>
#include <vector >
#include<string.h>
usingnamespace std ;
int main () {
int index;
vector<string>names;
vector<int>passwords;
vector<int>account;
vector<string>::const_iterator i;
names.push_back("mohammad");names.push_back("Khaled");names.push_back("Ahmmad");
passwords.push_back(3421);passwords.push_back(1416);passwords.push_back(2776);
account.push_back(800);account.push_back(1000000);account.push_back(5000);
char answr;
cout<<" Do you have account ? y\n";
cin>>answr;
if ( answr =='y'||'Y')
{
cout<<"Enter your name : "<<endl;
char name;
cin>>name;
for( i=names.begin();i!=names.end();i++)
{
if (names at.(i)==name)//
index=i;
}
while(1)
{
char password ;
cout<<"ENTER YOUR PASSOWRD :\n";
cin>>password;
if(password==passwords at.[index])//
{cout<<"loge in is completed";
break;}
else
cout<<"the name dosn't match the password ,try again";
}
yeah i found errors and c corrected it , it worked fine but when i enter the name and the password every time it give me the else statement.
I'm using Microsoft Visual 2010 Express
0. mohammad 3421
1. khaled 1416
2. ahmmad 2776
searching for user name 'khaled' with password 1416
user name 'khaled' was found at position 1
passords[1] is 1416
login successful