Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. bool IsLoggedIn()
  8. {
  9.  
  10. string username, password, un, pw;
  11.  
  12.  
  13. cout << "Unesite Username: "; cin >> username;
  14. cout << "Unesite Password: "; cin >> password;
  15.  
  16.  
  17. ifstream read("d:\\" + username + ".txt");
  18. getline(read, un);
  19. getline(read, pw);
  20.  
  21. if (un == username && pw == password )
  22. {
  23. return true;
  24. }
  25. else
  26. {
  27. return false;
  28. }
  29.  
  30. }
  31.  
  32.  
  33. int main()
  34. {
  35.  
  36. int choice;
  37. cout << "1: Registracija\n2: Login\nIzbornik: "; cin >> choice;
  38. if (choice == 1)
  39. {
  40.  
  41. string username, age, password;
  42.  
  43.  
  44.  
  45. cout << "Izaberite Zeljeni UserName: "; cin >> username;
  46. cout << "Izaberite Zeljene godine: "; cin >> age;
  47. cout << "Izaberite Zeljenu Lozinku: "; cin >> password;
  48.  
  49.  
  50.  
  51. ofstream file;
  52. file.open("d:\\" + username + ".txt");
  53. file << username;
  54. file << endl;
  55. file << password;
  56. file.close();
  57.  
  58. main();
  59.  
  60.  
  61.  
  62. }
  63. else if (choice == 2)
  64. {
  65.  
  66. bool status = IsLoggedIn();
  67.  
  68. if (!status)
  69. {
  70. cout << "[ERROR]" << endl;
  71. system("COLOR 4f");
  72. system("PAUSE");
  73. return 1;
  74.  
  75. }
  76. else
  77. {
  78. cout << "[USPIJESNO]" << endl;
  79. system("COLOR 2f");
  80. system("PAUSE");
  81. return 0;
  82.  
  83. }
  84.  
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement