What I am working on ( My first program) is a password keeper that would store and hold your passwords for you and is basically user friendly. There is a problem which i am encountering however and is this:
This is my code as it stands now. The problems I am facing are that the input == master_password says it does not recognize "operator==" so I was wondering if there is another way to check if the input by the user is equal to the stored password. The other problem or question i have is that I am storing all the passwords in different files which when ever that string inside the file was needed, the file would have to be opened then closed. So I was wondering if it was more efficient to somehow store all the passwords in one file so i wouldn't have to open each and every file for outputting the password names and actual passwords and how I could do that.Code:#include <fstream> #include <iostream> using namespace std; int main() { int input; int second_input; std::string master_password; std::string first_password; std::string second_password; std::string third_password; std::string fourth_password; std::string first_password_name; std::string second_password_name; std::string third_password_name; std::string fourth_password_name; cout<<"You have initiazilized Password Keeper,\n"; cout<<"a program which stores your passwords \n"; cout<<"in a password protected enviorment.\n"; cout<<" \n"; do { cout<<"\n"; cout<<"Please enter the password to access your \n"; cout<<"passwords: "; cin>> input; cin.ignore(); if ( input == master_password ) { cout<<" \n"; cout<<"Access Granted.\n"; cout<<"\n"; cout<<"1."<< first_password_name<<".\n"; cout<<"2."<< second_password_name<<".\n"; cout<<"3."<< third_password_name <<"\n"; cout<<"4."<< fourth_password_name<<".\n"; cout<<"5.Password Managment.\n"; cout<<"Input the password you would desire: "; cin>> second_input; cin.ignore(); switch ( second_input ) { case 1: cout<<"\n"; cout<<"Your "<< first_password_name<<" is "<< first_password <<".\n"; break; case 2: cout<<"\n"; cout<<"Your "<< second_password_name<<" is "<< second_password<<"\n"; break; case 3: cout<<"\n"; cout<<"Your"<< third_password_name<<" is "<< third_password <<"\n"; break; case 4: cout<<"\n"; cout<<"Your"<< fourth_password_name<<" is "<< fourth_password <<"\n"; break; case 5: cout<<"\n"; cout<<"Password Managment accessed."; do { cout<<"\n"; cout<<"1.Edit Master password.\n"; cout<<"2.Edit First password name.\n"; cout<<"3.Edit First password.\n"; cout<<"4.Edit Second password name.\n"; cout<<"5.Edit Second passsword.\n"; cout<<"6.Edit Third password name.\n"; cout<<"7.Edit Third password.\n"; cout<<"8.Edit Fourth password name.\n"; cout<<"9.Edit Fourth password.\n"; cout<<"10.Quit.\n"; cout<<"What would you like to do: "; cin>> input; switch ( input ) { case 1: { ofstream myfile ("master_password.txt"); cout<<"Enter the master password you would desire: "; cin>> master_password; myfile << master_password; myfile.close(); input<< 0; break; } case 2: { ofstream fpnfile ("first_password_name.txt"); cout<<"\n"; cout<<"\n"; cout<<"Enter the new name of you first password i.e.'Email': "; cin>>first_password_name; fpnfile << first_password_name; fpnfile.close(); input<< 0; break; } case 3: { ofstream fpfile ("first_password.txt"); cout<<"\n"; cout<<"\n"; cout<<"Enter the new atcual first password: "; cin>>first_password; fpfile << first_password; fpfile.close(); input<< 0; break; } } } while ( input !=10, input < 11 ); break; default: cout<<"Incorrect Selection"; break; } } else { cout<<"\n"; cout<<"Access Denied.\n"; break; } } while ( input != 908 ) ; cin.get(); }
Thanks!,
A13W![]()



LinkBack URL
About LinkBacks



