fork(1) download
  1. #include <iostream>
  2. #include <map>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main() {
  7. // create your dictonary
  8. map<string, string>dict = { {"john", "123"} };
  9. string username, password;
  10. cout<<"Enter username: "<<endl;
  11. cin>>username;
  12. cout<<"Enter password: "<<endl;
  13. cin>>password;
  14. // Check if provided username and password matches with the one is dictonary
  15. if(dict.find(username) != dict.end() && dict[username] == password) {
  16. cout<<"Login Successfully!";
  17. } else {
  18. cout<<"Invalid Credentials";
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5452KB
stdin
john
123
stdout
Enter username: 
Enter password: 
Login Successfully!