Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. string login(string username, string password)
  8. {
  9. string un, pw;
  10. ifstream read("../../" + username + ".txt");
  11. getline(read, un);
  12. getline(read, pw);
  13.  
  14. if (un == username && pw == password)
  15. {
  16. //cout << "Succesfully logged in!" << endl;
  17. string result = "success";
  18. return result;
  19. }
  20. else
  21. {
  22. //cout << "False login!" << endl;
  23. string result = "failure";
  24. return result;
  25. }
  26. }
  27.  
  28. int main()
  29. {
  30.  
  31. cout << "Please login: " << endl;
  32.  
  33. string username, password;
  34.  
  35. cout << "Enter username: "; cin >> username;
  36. cout << "Enter password: "; cin >> password;
  37.  
  38. cout << login();
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement