i think this part got problem..anyone can guide me?
ifstream BanKing;
BanKing.open("BankData.txt");
while (!BanKing.eof())
{
BanKing>>loginName;
BanKing>>password;
if(loginName == loginName1 && password == password1)
{
menu();
break;
}
else
{
cout<<"\tUnregistered ID or you have enter a wrong password !"<<endl;
cin.clear();
cin.ignore();
getchar();
return ;
}
BanKing.close();
}
}
i got a function that get the input of login id and password and store in a file,
void registeration()
{
fstream BanKing;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
cout <<"\tEnter 'Q' to return to quit."<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
cout<<"\tEnter desired login ID: ";
getline(cin, loginName);
cout<<endl;
if(loginName == "q" || loginName == "Q")
{
system("cls");
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 13);
header3();
return ;
}
cout<<"\tEnter desired password(in digit): ";
cin>>password;
cout<<endl;
if (password >= 10000)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 2);
cout <<" \t\t\t------------------------------"<<endl;
cout <<"\t\t\t [Password secure level : Strong]"<<endl;
cout <<"\t\t\t ------------------------------"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
}
if (password < 10000)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 12);
cout <<"\t\t\t ----------------------------"<<endl;
cout<<" \t\t\t [Password secure level : Weak]"<<endl;
cout <<"\t\t\t ----------------------------"<<endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 15);
cout<<"\tPlease insert a new 5-digits password : ";
cin>> password ;
cout<<"\tYour password has been changed !! " <<endl;
}
BanKing.open("BankData.txt", ios::out);
if (BanKing.is_open())
BanKing<<loginName <<"\t";
BanKing<<password <<"\t";
BanKing.put('\n');
BanKing.close();
reminder();
cout<<endl;
registerProfile();
system("cls");
}
then i use a function that can login by compare the login id and password inserted..
the problem is after i inserted the password and login id to login, it just jump out and close the cmd
what is the problem?
text file:
BankData.txt
hao 12345
savedData.txt
1
1
10000
0
0