Guest User

Untitled

a guest
Jul 3rd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8.  
  9. void Login();
  10.  
  11. int main()
  12. {
  13.     Login();
  14.     return 0;
  15. }
  16.  
  17. void Login()
  18. {
  19.     char login_un[50], login_pw[50], username[50], password[50];
  20.     int c;
  21.     ifstream uin("user.txt");
  22.     ifstream pin("pass.txt");
  23.  
  24.     cout<<"Main\n\n"
  25.         <<"(1) Login\n"
  26.         <<"(2) Quit\n";
  27.     cin>> c;
  28.  
  29.  
  30.  
  31.     if (c==1)
  32.     {
  33.         uin.getline(username, 50);
  34.         while (strcmp(login_un, username) !=0)
  35.         {
  36.             cout<<"Username: ";
  37.             cin.getline(login_un, 50);
  38.             if (strcmp(login_un, username) ==0) break;
  39.             else
  40.                 cout<<"\nInvalid Username.\n";
  41.         }
  42.  
  43.         pin.getline(password, 50);
  44.         while (strcmp(login_pw, password) !=0)
  45.         {
  46.             cout<<"\nPassword: ";
  47.             cin.getline(login_pw, 50);
  48.             if (strcmp(login_pw, password) ==0) break;
  49.             else
  50.                 cout<<"\nInvalid Password\n";
  51.         }
  52.  
  53.     }
  54.  
  55.     else if (c==2)
  56.     {
  57.         cout<<"Quitting\n";
  58.         exit(1);
  59.     }
  60.     return;
  61. }
Add Comment
Please, Sign In to add comment