Advertisement
Guest User

Untitled

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