Advertisement
Guest User

Untitled

a guest
Mar 13th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3.  
  4. using namespace std;
  5.  
  6. bool IsSignedIn ()
  7. {
  8. string username, password, us, pa;
  9.  
  10. cout<<"Enter username:"; cin >> username;
  11. cout<<"Enter password:"; cin >> password;
  12.  
  13. ifstream read("data\\" = username + ".txt");
  14. getline(read, us);
  15. getline(read, pa);
  16.  
  17. if (un == username && pa == password)
  18. {
  19. return true;
  20. }
  21. else
  22. {
  23. return false;
  24. }
  25. }
  26.  
  27. int main()
  28. {
  29. int choice;
  30. cout<<"1:Register\n2: Login\nYour Choice: "; cin >> choice;
  31. if ( choice == 1)
  32. {
  33. string username, password;
  34. cout<< "select a username": cin >> username;
  35. cout<< "select a password": cin >> password;
  36.  
  37. ofstream file;
  38. file.open("data\\" + username + ".txt");
  39. file << username << endl << password;
  40. file.close();
  41.  
  42. main();
  43. }
  44. else if (choice == 2)
  45. {
  46. bool status = IsSignedIn();
  47. if (!status)
  48. {
  49. cout << "Incorrect Login!" << endl;
  50. system ("PAUSE");
  51. return 0;
  52. }
  53. else
  54. {
  55. cout << "Login has been Successful!" << endl;
  56. system ("PAUSE");
  57. return 1;
  58. }
  59. }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement