Advertisement
Guest User

Untitled

a guest
Oct 28th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <fstream>
  4. #include <string>
  5. using namespace std;
  6.  
  7.  
  8. void Login();
  9. bool CheckCredentials(string, string);
  10.  
  11.  
  12. int main()
  13. {
  14.  
  15. string username;
  16. string password;
  17.  
  18.  
  19. Login();
  20. CheckCredentials(username, password);
  21.  
  22. return 0;
  23. }
  24. void Login()
  25. {
  26. ifstream infile;
  27. string username;
  28. string password;
  29. int tries = 0;
  30.  
  31. while (tries < 3)
  32. {
  33. cout << "Enter in your username and password." << endl;
  34. cout << "Username: ";
  35. cin >> username;
  36. cout << "Password: ";
  37. cin >> password;
  38.  
  39.  
  40. }
  41. if (!CheckCredentials(username, password) && tries < 3)
  42. {
  43. tries++;
  44. cout << "Wrong password or username. you have " << 3 - tries << "tries left" << endl;
  45.  
  46.  
  47. }
  48. if (tries > 2)
  49. {
  50. cout << "You have exceeded the maximum amount of attempts. Try again in 24 hours." << endl;
  51. }
  52. if (CheckCredentials(username, password))
  53. {
  54. cout << "Access Granted" << endl;
  55. }
  56. }
  57.  
  58. bool CheckCredentials(string username, string password)
  59. {
  60.  
  61. ifstream inFile;
  62.  
  63. inFile.open("correctData.txt");
  64. if (CheckCredentials(username,password))
  65. {
  66. inFile >> username;
  67. inFile >> password;
  68. inFile.close();
  69.  
  70. }
  71. else
  72. {
  73.  
  74. }
  75.  
  76. return true;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement